public ActionResult Edit([Bind(Include = "idProjectFKPK,idModuleFKPK,idRequerimentPK,idEmployeeFK,objective,estimatedDuration,realDuration,status,startingDate,endDate,complexity")] Requeriment requeriment) { if (ModelState.IsValid) { if (requeriment.startingDate < requeriment.endDate) { int OidModuleFKPK = Convert.ToInt32(Request["idModuleFKPK"]); if (OidModuleFKPK != requeriment.idModuleFKPK) { var reqToDelete = db.Requeriment.Where(r => r.idModuleFKPK == OidModuleFKPK && r.idProjectFKPK == requeriment.idProjectFKPK && r.idRequerimentPK == requeriment.idRequerimentPK).FirstOrDefault(); db.Requeriment.Remove(reqToDelete); db.Requeriment.Add(requeriment); } else { db.Entry(requeriment).State = EntityState.Modified; } db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("startingDate", "La fecha de inicio no puede ser despues de la fecha de finalización."); } } ViewBag.idModuleFKPK = new SelectList(db.Module.Where(x => x.idProjectFKPK == requeriment.idProjectFKPK), "idModulePK", "name", requeriment.idModuleFKPK); var employeeController = new EmployeesController(); ViewBag.idEmployeeFK = employeeController.EmployeeFromTeamSelectList(requeriment.idProjectFKPK, Convert.ToInt32(requeriment.idEmployeeFK)); ViewBag.complexity = SelectListComplexity(requeriment.complexity); ViewBag.status = SelectListStatus(requeriment.status); return(View(requeriment)); }
// GET: Requeriments/Details/5 //EFE: Detalles del Requerimiento seleccionado. public ActionResult Details(int?idProjectFKPK, int?idModuleFKPK, int?idRequerimentPK) { if (idProjectFKPK == null || idModuleFKPK == null || idRequerimentPK == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewBag.isLogged = false; var employeeController = new EmployeesController(); foreach (var employee in employeeController.EmployeeFromTeamSelectList(idProjectFKPK, null)) //Obtenemos a los miembros del equipo { if (employee.Value == Session["userID"].ToString()) //Si un miembro del equipo esta logueado { ViewBag.isLogged = true; break; } } Requeriment requeriment = db.Requeriment.Find(idProjectFKPK, idModuleFKPK, idRequerimentPK); if (requeriment == null) { return(HttpNotFound()); } return(View(requeriment)); }
// GET: Requeriments/Create //EFE: Crea un requerimieno ya asociado a un módulo y proyecto public ActionResult Create(int?idProjectFKPK, int?idModuleFKPK) { if (idProjectFKPK == null || idModuleFKPK == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var moduleController = new ModulesController(); var employeeController = new EmployeesController(); Module module = moduleController.GetModule(idProjectFKPK, idModuleFKPK); Requeriment requeriment = new Requeriment { Module = module, idModuleFKPK = module.idModulePK, idProjectFKPK = module.idProjectFKPK }; ViewBag.idEmployeeFK = employeeController.EmployeeFromTeamSelectList((int)idProjectFKPK, null); ViewBag.complexity = SelectListComplexity(null); ViewBag.status = SelectListStatus(null); return(View(requeriment)); }
// GET: Requeriments/Edit/5 //EFE: Edita un requerimiento seleccionado public ActionResult Edit(int?idProjectFKPK, int?idModuleFKPK, int?idRequerimentPK) { if (idProjectFKPK == null || idModuleFKPK == null || idRequerimentPK == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Requeriment requeriment = db.Requeriment.Find(idProjectFKPK, idModuleFKPK, idRequerimentPK); if (requeriment == null) { return(HttpNotFound()); } var employeeController = new EmployeesController(); ViewBag.idEmployeeFK = employeeController.EmployeeFromTeamSelectList(requeriment.idProjectFKPK, Convert.ToInt32(requeriment.idEmployeeFK)); ViewBag.idModuleFKPK = new SelectList(db.Module.Where(x => x.idProjectFKPK == idProjectFKPK), "idModulePK", "name", requeriment.idModuleFKPK); ViewBag.complexity = SelectListComplexity(requeriment.complexity); ViewBag.status = SelectListStatus(requeriment.status); return(View(requeriment)); }
public ActionResult Create([Bind(Include = "idProjectFKPK,idModuleFKPK,idRequerimentPK,idEmployeeFK,estimatedDuration,realDuration,status,startingDate,endDate,complexity,objective")] Requeriment requeriment) { if (ModelState.IsValid) { if (requeriment.startingDate < requeriment.endDate) { db.Requeriment.Add(requeriment); db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("startingDate", "La fecha de inicio no puede ser despues de la fecha de finalización."); } } var employeeController = new EmployeesController(); ViewBag.idEmployeeFK = employeeController.EmployeeFromTeamSelectList(requeriment.idProjectFKPK, Convert.ToInt32(requeriment.idEmployeeFK)); ViewBag.complexity = SelectListComplexity(requeriment.complexity); ViewBag.status = SelectListStatus(requeriment.status); return(View(requeriment)); }