コード例 #1
0
 //
 // GET: /Customer/Delete/5
 public ActionResult Delete(int id)
 {
     Customer customer = _customerService.Get(id);
     var custToDisplay = new CustomerViewModel
                             {
                                 Id = customer.Id,
                                 FirstName = customer.FirstName,
                                 MI = customer.MI,
                                 LastName = customer.LastName,
                                 ModifiedDate = customer.ModifiedDate
                             };
     return View(custToDisplay);
 }
コード例 #2
0
 public ActionResult Create(Customer customer)
 {
     try
     {
         _customerService.Add(customer);
         var custToDisplay = new CustomerViewModel
                                 {
                                     Id = customer.Id,
                                     FirstName = customer.FirstName,
                                     MI = customer.MI,
                                     LastName = customer.LastName,
                                     ModifiedDate = customer.ModifiedDate
                                 };
         return RedirectToAction("Index", custToDisplay);
     }
     catch
     {
         return View();
     }
 }
コード例 #3
0
 public ActionResult Delete(int Id, Customer customer)
 {
     try
     {
         Customer customerToDelete = _customerService.Get(Id);
         _customerService.Delete(Id, customerToDelete);
         var custToDisplay = new CustomerViewModel
                                 {
                                     Id = customer.Id,
                                     FirstName = customerToDelete.FirstName,
                                     MI = customerToDelete.MI,
                                     LastName = customerToDelete.LastName,
                                     ModifiedDate = customerToDelete.ModifiedDate
                                 };
         return RedirectToAction("Index", custToDisplay);
     }
     catch
     {
         return View();
     }
 }
コード例 #4
0
 public ActionResult Details(int id)
 {
     Customer customer = _customerService.Get(id);
     var custToDisplay = new CustomerViewModel
                             {
                                 Id = customer.Id,
                                 CustomerName = customer.CustomerName,
                                 FirstName = customer.FirstName,
                                 MI = customer.MI,
                                 LastName = customer.LastName,
                                 ModifiedDate = customer.ModifiedDate
                             };
     return custToDisplay.Id > 0 ? View(custToDisplay) : View("No data found");
 }