コード例 #1
0
        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));
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
        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"));
        }