Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrency Stamp Implementation to modules #9838

Merged
merged 12 commits into from
Sep 2, 2021
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Domain.Entities;

namespace Volo.Abp.Data
{
public static class ConcurrencyStampExtensions
{
public static void SetConcurrencyStamp(this IHasConcurrencyStamp entity, string concurrencyStamp)
enisn marked this conversation as resolved.
Show resolved Hide resolved
{
if (!concurrencyStamp.IsNullOrEmpty())
{
entity.ConcurrencyStamp = concurrencyStamp;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Identity;
using Volo.Abp.Validation;

Expand All @@ -28,7 +29,7 @@ public async Task<IViewComponentResult> InvokeAsync()
return View("~/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml", model);
}

public class PersonalInfoModel
public class PersonalInfoModel : IHasConcurrencyStamp
{
[Required]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
Expand All @@ -51,6 +52,9 @@ public class PersonalInfoModel
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))]
[Display(Name = "DisplayName:PhoneNumber")]
public string PhoneNumber { get; set; }

[HiddenInput]
public string ConcurrencyStamp { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

<h4>@L["PersonalSettings"]</h4><hr/>
<form method="post" id="PersonalSettingsForm">

<abp-input asp-for="ConcurrencyStamp" />

<abp-input asp-for="UserName" readonly="!isUserNameUpdateEnabled"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities;

namespace Volo.Blogging.Admin.Blogs
{
public class UpdateBlogDto
public class UpdateBlogDto : IHasConcurrencyStamp
{
[Required]
public string Name { get; set; }
Expand All @@ -11,5 +12,7 @@ public class UpdateBlogDto
public string ShortName { get; set; }

public string Description { get; set; }

public string ConcurrencyStamp { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching;
using Volo.Abp.Data;
using Volo.Blogging.Blogs;
using Volo.Blogging.Blogs.Dtos;
using Volo.Blogging.Posts;
Expand Down Expand Up @@ -58,6 +59,7 @@ public async Task<BlogDto> UpdateAsync(Guid id, UpdateBlogDto input)
blog.SetName(input.Name);
blog.SetShortName(input.ShortName);
blog.Description = input.Description;
blog.SetConcurrencyStamp(input.ConcurrencyStamp);

return ObjectMapper.Map<Blog, BlogDto>(blog);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Validation;
using Volo.Blogging.Admin.Blogs;
using Volo.Blogging.Blogs;
Expand Down Expand Up @@ -53,7 +54,7 @@ await _blogAppService.UpdateAsync(Blog.Id, new UpdateBlogDto()
return Page();
}

public class BlogEditViewModel
public class BlogEditViewModel : IHasConcurrencyStamp
{
[HiddenInput]
[Required]
Expand All @@ -69,8 +70,9 @@ public class BlogEditViewModel

[DynamicStringLength(typeof(BlogConsts), nameof(BlogConsts.MaxDescriptionLength))]
public string Description { get; set; }

[HiddenInput]
public string ConcurrencyStamp { get; set; }
}
}


}
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
using Volo.Blogging.Posts;

namespace Volo.Blogging.Comments.Dtos
{
public class CommentWithDetailsDto : FullAuditedEntityDto<Guid>
public class CommentWithDetailsDto : FullAuditedEntityDto<Guid>, IHasConcurrencyStamp
{
public Guid? RepliedCommentId { get; set; }

public string Text { get; set; }

public BlogUserDto Writer { get; set; }

public string ConcurrencyStamp { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities;

namespace Volo.Blogging.Comments.Dtos
{
public class UpdateCommentDto
public class UpdateCommentDto : IHasConcurrencyStamp
{
[Required]
public string Text { get; set; }
public string ConcurrencyStamp { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
using Volo.Blogging.Tagging.Dtos;

namespace Volo.Blogging.Posts
{
public class PostWithDetailsDto : FullAuditedEntityDto<Guid>
public class PostWithDetailsDto : FullAuditedEntityDto<Guid>, IHasConcurrencyStamp
{
public Guid BlogId { get; set; }

Expand All @@ -28,5 +29,7 @@ public class PostWithDetailsDto : FullAuditedEntityDto<Guid>
public BlogUserDto Writer { get; set; }

public List<TagDto> Tags { get; set; }

public string ConcurrencyStamp { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using Volo.Abp.Domain.Entities;

namespace Volo.Blogging.Posts
{
public class UpdatePostDto
public class UpdatePostDto : IHasConcurrencyStamp
{
public Guid BlogId { get; set; }

Expand All @@ -23,5 +23,7 @@ public class UpdatePostDto
public string Description { get; set; }

public string Tags { get; set; }

public string ConcurrencyStamp { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Data;
using Volo.Abp.Guids;
using Volo.Blogging.Comments.Dtos;
using Volo.Blogging.Posts;
Expand Down Expand Up @@ -99,6 +100,7 @@ public async Task<CommentWithDetailsDto> UpdateAsync(Guid id, UpdateCommentDto i
await AuthorizationService.CheckAsync(comment, CommonOperations.Update);

comment.SetText(input.Text);
comment.SetConcurrencyStamp(input.ConcurrencyStamp);

comment = await _commentRepository.UpdateAsync(comment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Volo.Blogging.Tagging;
using Volo.Blogging.Tagging.Dtos;
using Volo.Blogging.Users;
using Volo.Abp.Data;

namespace Volo.Blogging.Posts
{
Expand Down Expand Up @@ -173,6 +174,7 @@ public async Task<PostWithDetailsDto> UpdateAsync(Guid id, UpdatePostDto input)

post.SetTitle(input.Title);
post.SetUrl(input.Url);
post.SetConcurrencyStamp(input.ConcurrencyStamp);
post.Content = input.Content;
post.Description = input.Description;
post.CoverImage = input.CoverImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
<div>
<form class="editFormClass">
<input name="commentId" value="@commentWithRepliesDto.Comment.Id" hidden />
<input name="concurrencyStamp" value="@commentWithRepliesDto.Comment.ConcurrencyStamp" hidden />
enisn marked this conversation as resolved.
Show resolved Hide resolved
<div class="form-group">
<textarea class="form-control" name="text" id="textBoxId" rows="4">@commentWithRepliesDto.Comment.Text</textarea>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<div class="card">
<div class="card-body">
<form method="post" id="edit-post-form">

<abp-input asp-for="Post.ConcurrencyStamp" />

<abp-input asp-for="Post.Title" auto-focus="true" />

<abp-alert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Validation;
using Volo.Blogging.Blogs;
using Volo.Blogging.Pages.Blogs.Shared.Helpers;
Expand Down Expand Up @@ -75,7 +76,8 @@ public virtual async Task<ActionResult> OnPostAsync()
}
}

public class EditPostViewModel
public class EditPostViewModel : IHasConcurrencyStamp

{
[Required]
[HiddenInput]
Expand Down Expand Up @@ -106,5 +108,8 @@ public class EditPostViewModel
public string Description { get; set; }

public string Tags { get; set; }

[HiddenInput]
public string ConcurrencyStamp { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@
id: form.commentId,
commentDto: {
text: form.text,
// TODO: Implement concurrencyStamp here:
//concurrencyStamp: form.concurrencyStamp
},
},
success: function (response) {
$('div .editForm').hide();
$('#' + form.commentId).text(form.text);
//$(this).find('[name=concurrencyStamp]').val(response.concurrencyStamp);
},
});
});
Expand Down