public Model.Supplier SupplierFormView_GetItem([RouteData] int id) { try { SupplierService supplierservice = new SupplierService(); return supplierservice.GetSupplier(id); } catch (Exception) { ModelState.AddModelError(String.Empty, "Ett fel inträffade"); return null; } }
public void FormView_InsertItem(Model.Supplier supplier) { if (ModelState.IsValid) { try { var supplierService = new SupplierService(); supplierService.InsertSupplier(supplier); Session["saved"] = true; Response.Redirect("~/leverantörer"); } catch (Exception) { ModelState.AddModelError(String.Empty, "Ett fel inträffade när kontakten skulle sparas"); } } }
//spara ny kund public void FormView_InsertItem(Model.Supplier supplier) { if (ModelState.IsValid) { try { var supplierService = new SupplierService(); supplierService.InsertSupplier(supplier); Session["saved"] = true; Response.RedirectToRoute("ListSupplier", null); Context.ApplicationInstance.CompleteRequest(); } catch (Exception) { ModelState.AddModelError(String.Empty, "Ett fel inträffade när kontakten skulle sparas"); } } }