Compare commits

...

2 Commits

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