public IActionResult RemovePostPart([FromBody] PostPartIdParameters model) { Claim idClaim = User.FindFirst("sub"); RemovePostPartReturnModel ret = _postPartService.RemovePostPart(model.PostPartId, idClaim.Value); if (ret.IsActionSucceed) { // Publish to remove Image _bus.Publish <PostPartRemovedAction>(new PostPartRemovedAction() { PostPartId = model.PostPartId, DateUtcAction = DateTime.UtcNow, LargeUrl = ret.LargeImageUrl, SmallUrl = ret.SmallImageUrl, ThumbUrl = ret.ThumbImageUrl }); } return(Ok(Json(ret))); }
public RemovePostPartReturnModel RemovePostPart(int PostPartId, string currUserId) { RemovePostPartReturnModel ret = new RemovePostPartReturnModel() { IsActionSucceed = false }; if (string.IsNullOrEmpty(currUserId)) { return(ret); } PostPart ppart = _postPartSet.Include(p => p.Post).Include(p => p.Image).FirstOrDefault(p => p.Id == PostPartId); if (ppart.Post.UserInfoId != currUserId) { return(ret); } ppart.IsSoftDeleted = true; if (ppart.Image != null) { ret.SmallImageUrl = ppart.Image.SmallPath; ret.LargeImageUrl = ppart.Image.ResizedPath; ret.ThumbImageUrl = ppart.Image.ThumbPath; } _postPartSet.Update(ppart); int z = _entityContext.SaveChanges(); if (z == 0) { ret.IsActionSucceed = false; } ret.IsActionSucceed = true; return(ret); }