public ActionResult Edit(Guid id) { CustomerRepositery custRep = new CustomerRepositery(); CustomersModel custModel = new CustomersModel(); Customers customer = custRep.GetById(id); custModel.Code = customer.Code; custModel.Customer_ID = customer.Customer_ID; custModel.Name = customer.Name; return(View("EditCustomer", custModel)); }
public ActionResult Delete(Guid id) { ProjetController prjtControleur = new ProjetController(); CustomerRepositery cutoRepo = new CustomerRepositery(); Customers cutomer = cutoRepo.GetById(id); ProjetRepositery prjtRepo = new ProjetRepositery(); List <Projects> projets = prjtRepo.GetByCustomerId(id).ToList(); foreach (var pro in projets) { prjtControleur.Delete(pro.Project_ID); } prjtRepo.Save(); cutoRepo.Delete(cutomer); cutoRepo.Save(); return(RedirectToAction("AllCustomer")); }
public ActionResult updateCustomers(Guid id) { CustomerRepositery custRep = new CustomerRepositery(); Customers customer = custRep.GetById(id); if (!ModelState.IsValidField("Name") || !ModelState.IsValidField("Code")) { CustomersModel custModel = new CustomersModel(); custModel.Code = customer.Code; custModel.Customer_ID = customer.Customer_ID; custModel.Name = customer.Name; return(View("EditCustomer", custModel)); } String name = Convert.ToString(Request.Form["Name"]); String code = Convert.ToString(Request.Form["Code"]); custRep.updateCustomers(customer, name, code); return(RedirectToAction("AllCustomer")); }