update post details for blog
This commit is contained in:
parent
8cede3ba55
commit
912457755e
@ -75,9 +75,16 @@ namespace PortBlog.API.Controllers
|
||||
postEntityExists.Views++;
|
||||
|
||||
_blogRepository.AddPost(postEntityExists);
|
||||
|
||||
await _blogRepository.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
postEntityExists.Title = post.Title;
|
||||
postEntityExists.Description = post.Description;
|
||||
postEntityExists.Categories = post.Categories;
|
||||
_blogRepository.UpdatePost(postEntityExists);
|
||||
}
|
||||
|
||||
await _blogRepository.SaveChangesAsync();
|
||||
|
||||
var postMetrics = _mapper.Map<PostMetricsDto>(postEntityExists);
|
||||
postMetrics.PostExists = true;
|
||||
|
||||
@ -16,7 +16,7 @@ namespace PortBlog.API.Profiles
|
||||
)
|
||||
.ForMember(
|
||||
dest => dest.ModifiedDate,
|
||||
opts => opts.MapFrom(src => src.ModifiedDate != null ? src.ModifiedDate.Value.ToString("MMM dd, yyyy") : string.Empty)
|
||||
opts => opts.MapFrom(src => !string.IsNullOrEmpty(src.ModifiedDate.ToString()) ? src.ModifiedDate.Value.ToString("MMM dd, yyyy") : string.Empty)
|
||||
);
|
||||
CreateMap<Post, PostMetricsDto>();
|
||||
CreateMap<PostCreationDto, Post>();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user