コード例 #1
0
 public void Save(Customer customer)
 {
     if (customer.Id == 0) {
         customer.Id = _customers.Count;
     }
     _customers[customer.Id] = customer;
 }
コード例 #2
0
 public Repository()
 {
     _customers[0] = new Customer {
         Id = 1,
         FirstName = "Eric",
         LastName = "Siebeneich",
         PhoneNumber = "1234567980"
     };
 }
コード例 #3
0
        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();
            }
        }