public void Save(Customer customer) { if (customer.Id == 0) { customer.Id = _customers.Count; } _customers[customer.Id] = customer; }
public Repository() { _customers[0] = new Customer { Id = 1, FirstName = "Eric", LastName = "Siebeneich", PhoneNumber = "1234567980" }; }
public ActionResult Create(CustomerViewModel vm) { try { Customer cust = new Customer { FirstName = vm.FirstName, LastName = vm.LastName, PhoneNumber = vm.PhoneNumber }; _repo.Save(cust); return RedirectToAction("Index"); } catch { return View(); } }