Merge pull request 'update post details for blog' (#1) from dev into prod

Reviewed-on: #1
This commit is contained in:
rajukottedi 2025-01-06 00:01:01 +05:30
commit b4a9d797dd
2 changed files with 10 additions and 3 deletions

View File

@ -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;

View File

@ -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>();