public IActionResult EditAsync(PaperEditViewModel model) { if (!User.IsInRole("Admin")) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { try { if (_paperRepository.TitleTakenExcept(model.Title, model.Id)) { StatusMessage = "Error. This title is already taken."; return(RedirectToAction(nameof(Edit), model.Id)); } var paper = Mapper.Map <PaperDTO>(model); var result = _paperRepository.UpdatePaper(paper); if (result == 1) { StatusMessage = "Succesfully updated."; return(RedirectToAction(nameof(Index))); } } catch { StatusMessage = "Error. Something went wrong."; return(RedirectToAction(nameof(Index))); } } StatusMessage = "Error. Something went wrong."; return(RedirectToAction(nameof(Index))); }