private async Task<bool> ResolveDeleteRequest(DeleteViewModel model) { switch (model.Entity.ToLowerInvariant()) { case "book": return (await _bookProvider.DeleteBook(model.Id)) > 0; case "author": return (await _authorProvider.DeleteAuthor(model.Id)) > 0; case "category": return (await _categoryProvider.DeleteBookCategory(model.Id)) > 0; } return false; }
public async Task<ActionResult> Delete(DeleteViewModel model) { if (ModelState.IsValid) { var result = await ResolveDeleteRequest(model); if (result) { var manageVm = await LoadManageViewModel(); manageVm.HasChanges = true; manageVm.Success = true; return View("Index", manageVm); } } return View("Index", await LoadManageViewModel()); }