public ActionResult Delete(FormCollection collection, long[] ids) { if (ids.IsNullOrEmpty()) { FlashWarn("请选择一条数据"); return(View()); } var list = _service.GetByIds(ids); try { var r = _service.Delete(list.ToArray()); if (r.HasError) { FlashMessage(r); return(View(list)); } FlashSuccess("删除成功"); return(RedirectToAction("Index")); } catch (Exception e) { FlashError("删除失败"); return(View(list)); } }
public async Task <IActionResult> DeleteConfirmed(int id) { var developer = await _developerService.Get(id); await _developerService.Delete(developer); return(RedirectToAction(nameof(Index))); }
public ActionResult Delete(int?id, DeveloperViewModel developerViewModel) { try { var developer = developerService.GetByID((int)id); developerService.Delete(developer); developerService.Save(); return(RedirectToAction("Index")); } catch { ModelState.AddModelError("", "Database error!"); return(View(developerViewModel)); } }
public IHttpActionResult DeleteDeveloper(int id) { try { Developer Developer = DeveloperService.Delete(id); if (Developer == null) { return(NotFound()); } return(Ok(Developer)); } catch (RepositoryException ex) { return(InternalServerError(ex)); } }
public async Task DeleteTest() { var developer = new Developer(1, "Moq"); await developerService.Delete(developer); }
public void Delete(int id) => _service.Delete(id);