public void Edit(BookViewModel bookViewModel) { if (repo.IsAdmin()) { repo.Update(Mapper.Map <Book>(bookViewModel)); } else { throw new AccessViolationException(); } }
public async Task<ActionResult> Edit(Guid id, IFormCollection form) { try { await _booksRepo.Update(new Book() { Id = id, Title = form["Title"], Author = form["Author"], ReleaseDate = Convert.ToDateTime(form["ReleaseDate"]), Description = form["Description"] }); return RedirectToAction(nameof(Index)); } catch { return View(); } }