// GET: Projet public ActionResult Index(Guid?id_Customer) { ProjetRepositery prtRep = new ProjetRepositery(); ProjectsModel prjtModel = new ProjectsModel(); if (prtRep.getAllCustomers().ToList().Count() == 0 || prtRep.getAllPoles().ToList().Count() == 0) { ViewData["erreur"] = "Customers et des Poles "; return(View("ErrorEmptyElement")); } prjtModel.CustomersList = prtRep.getAllCustomers().ToList(); prjtModel.PolesList = prtRep.getAllPoles().ToList(); ViewData["id_Customer"] = id_Customer; return(View("ProjectFormulaire", prjtModel)); }
public ActionResult updateProject(Guid id) { ProjetRepositery prtRep = new ProjetRepositery(); ProjectsModel prjtModel = new ProjectsModel(); Projects projet = prtRep.GetById(id); if (!ModelState.IsValidField("Name") || !ModelState.IsValidField("Budget")) { prjtModel.Project_ID = projet.Project_ID; prjtModel.Name = projet.Name; prjtModel.Description = projet.Description; prjtModel.CustomersList = prtRep.getAllCustomers().ToList(); prjtModel.PolesList = prtRep.getAllPoles().ToList(); return(View("EditProject", prjtModel)); } String name = Convert.ToString(Request.Form["Name"]); string description = Convert.ToString(Request.Form["Description"]); double budget = Convert.ToDouble(Request.Form["Budget"]); prtRep.updateProject(projet, name, description, budget); return(RedirectToAction("AllProjets")); }
public ActionResult createProject(ProjectsModel projetModel, Guid?id_Customer) { ProjetRepositery prtRep = new ProjetRepositery(); if (!ModelState.IsValidField("Name") || !ModelState.IsValidField("Budget")) { projetModel.CustomersList = prtRep.getAllCustomers().ToList(); projetModel.PolesList = prtRep.getAllPoles().ToList(); return(View("ProjectFormulaire", projetModel)); } ViewData["id_Customer"] = id_Customer; Projects projet = new Projects(); projet.Project_ID = Guid.NewGuid(); projet.Name = Convert.ToString(Request.Form["Name"]); projet.Description = Convert.ToString(Request.Form["Description"]); projet.Budget = Convert.ToDouble(Request.Form["Budget"]); projet.Customer_ID = id_Customer != null ? (Guid)id_Customer : new Guid(Convert.ToString(Request.Form["customersList"])); projet.Pole_ID = new Guid(Convert.ToString(Request.Form["polesList"])); prtRep.AddProjet(projet); return(RedirectToAction("AllProjets")); }