public string Delete(int id) { var logger = new FileSystemLogger(); var notifcation = new EmailSender.EmailSender(); try { var ordersData = new OrderRepository(); var customerHasOrders = ordersData.Get(id).Count > 0; if (customerHasOrders) { return "Unable to delete customer due to existing invoices."; } var customerDb = new CustomerRepository(); customerDb.Delete(id); notifcation.Send("*****@*****.**", "Customer Deleted", string.Format("Customer Deleted : ", id)); logger.Info("Deleted Customer with Id: {0}",id); return "Customer deleted"; } catch (Exception ex) { logger.Error(ex, "Error Deleting Customer Id: {0}", id); return "Unable to delete customer"; } }
public ActionResult Index() { var customerDb = new CustomerRepository(); var allCustomers = customerDb.Get(); return View(allCustomers); }