public ActionResult Edit(Customer model) { //Customer model = new Customer(); //if (model.CustomerId > 0) //{ // _customerRepository.UpdateCustomer(model); //} //return1 RedirectToAction("Index"); try { if (model != null) { if (model.CustomerId > 0) { _customerRepository.UpdateCustomer(model); } else { _customerRepository.CreateCustomer(model); } return Json(new { Error = false }); } return Json(new { Error = true, Message="Data saving error" }); } catch (Exception exc) { return Json(new { Error = true, Message = exc.Message }); } }
public void UpdateCustomer(Customer customer) { using (var db = getDatabase()) { db.EnableAutoSelect = false; db.Update("Customer", "CustomerId", customer); } }
public void CreateCustomer(Customer model) { using (var db = getDatabase()) { db.EnableAutoSelect = false; db.Insert("Customer","CustomerId", model); } }
public ActionResult Create(Customer model) { if (ModelState.IsValid) { _customerRepository.CreateCustomer(model); return RedirectToAction("Index"); } else { return View("Create"); } }