public async Task <Result <Meme> > EditMeme(EditMemeVM meme, int id, System.Security.Claims.ClaimsPrincipal user) { var entity = await _repository.FindAsync(id); if (entity == null) { throw new MemeSiteException(HttpStatusCode.NotFound, "Item not Found"); } if (entity.UserID == user.Claims.First(c => c.Type == "UserID").Value&& !entity.IsArchived) { entity.Title = meme.Title; entity.Txt = meme.Txt; entity.CategoryId = meme.CategoryId; return(await Update(entity)); } else { throw new MemeSiteException(HttpStatusCode.Forbidden, "You don't have permission to edit this"); } }
public async Task <IActionResult> EditMeme(int memeId, [FromBody] EditMemeVM editMeme) { var result = await _memeService.EditMeme(editMeme, memeId, User); return(Ok(result.Value)); }