public IActionResult Delete(int fanficId) { var fanfic = _fanficService.Get(fanficId); _fanficService.Delete(fanfic); return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> Delete([Required] string id) { if (ModelState.IsValid && User.Identity.IsAuthenticated) { FanficDTO fanfic = await _fanficService.GetById(id); ApplicationUser user = await _authenticationManager.UserManager.FindByNameAsync(User.Identity.Name); if (fanfic.ApplicationUserId == user.Id || await _authenticationManager.UserManager.IsInRoleAsync(user, "Admin")) { await DeleteFanficTagsByFanficId(id); await DeleteFanficChapters(id); await DeleteFanficComments(id); fanfic = await _fanficService.Delete(id); return(Ok(fanfic)); } } return(BadRequest(ModelState)); }