public void DeletePartBm(DeletePartBindingModel bind) { Part part = this.Context.Parts.Find(bind.PartId); this.Context.Parts.Remove(part); this.Context.SaveChanges(); }
public void DeletePart(DeletePartBindingModel bindingModel) { Part part = this.Context.Parts.Find(bindingModel.Id); if (part != null) { this.Context.Parts.Remove(part); this.Context.SaveChanges(); } }
public ActionResult Delete([Bind(Include = "Id")] DeletePartBindingModel bindingModel) { if (ModelState.IsValid) { this.service.DeletePart(bindingModel); return(this.RedirectToAction("AllParts")); } return(this.RedirectToAction("Delete", "Parts", new { id = bindingModel.Id })); }
public ActionResult Delete([Bind(Include = "PartId")] DeletePartBindingModel bind) { if (ModelState.IsValid) { this.service.DeletePartBm(bind); return(this.RedirectToAction("Index", "parts/all")); } var vm = this.service.GetDeleteVm(bind.PartId); return(View(vm)); }
public ActionResult Delete([Bind(Include = "PartId")] DeletePartBindingModel bind) { if (ModelState.IsValid) { this.service.DeletePart(bind); return(RedirectToAction("All")); } DeletePartViewModel model = this.service.DeleteViewModel(bind.PartId); return(this.View(model)); }