public void FormView_InsertItem(Model.Customer customer) { var customerService = new CustomerService(); customerService.InsertCustomer(customer); Session["saved"] = true; Response.Redirect("~/Pages/Customer/CustomerListing.aspx"); }
public Model.Customer CustomerFormView_GetItem([RouteData] int id) { try { CustomerService customerservice = new CustomerService(); return customerservice.GetCustomer(id); } catch (Exception) { ModelState.AddModelError(String.Empty, "Ett fel inträffade"); return null; } }
//spara ny kund public void FormView_InsertItem(Model.Customer customer) { if (ModelState.IsValid) { try { var customerService = new CustomerService(); customerService.InsertCustomer(customer); Session["saved"] = true; Response.RedirectToRoute("ListCustomer", null); Context.ApplicationInstance.CompleteRequest(); } catch (Exception) { ModelState.AddModelError(String.Empty, "Ett fel inträffade när kunden skulle sparas"); } } }