public void DeleteEmployee(int PersonId) { try { using (ProjectsDB db = new ProjectsDB()) { var employee = db.Staff.Where(s => s.PersonId == PersonId).FirstOrDefault(); if (employee != null) { db.Entry(employee).State = EntityState.Deleted; // Removing all dependencies foreach (var pe in db.ProjectExecutors.ToList()) { if (pe.ProjectExecutorId == PersonId) { db.ProjectExecutors.Remove(pe); } } foreach (var pi in db.ProjectInfo.ToList()) { if (pi.ProjectManagerId == PersonId) { db.ProjectInfo.Remove(pi); } } db.SaveChanges(); } } } catch (Exception ex) { throw new DBException("DeleteEmployee(): ", ex.ToString()); } }
public void DeleteProject(int ProjectId) { try { using (ProjectsDB db = new ProjectsDB()) { var project = db.ProjectInfo.Where(p => p.ProjectId == ProjectId).FirstOrDefault(); if (project != null) { db.Entry(project).State = EntityState.Deleted; // Removing dependencies foreach (var pe in db.ProjectExecutors.ToList()) { if (pe.ProjectId == ProjectId) { db.ProjectExecutors.Remove(pe); } } db.SaveChanges(); } } } catch (Exception ex) { throw new DBException("DeleteProject(): ", ex.ToString()); } }
public ActionResult Edit([Bind(Include = "ProjectID,Name,Description,Team")] Projects projects) { if (ModelState.IsValid) { db.Entry(projects).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(projects)); }
public ActionResult Edit([Bind(Include = "ErrorID,ErrorCode,ErrorCodeDescription,Subsystem,Component,FailureMode,FaultLogID")] ErrorCodes errorCodes) { if (ModelState.IsValid) { db.Entry(errorCodes).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(errorCodes)); }
public ActionResult Edit([Bind(Include = "FaultLogID,ProjectID,Date,Login,ErrorID,EventDescription,PartsReplaced,PartNumber,RecoverySteps,Hyperlinks,Results")] FaultRecoveryLog faultRecoveryLog) { if (ModelState.IsValid) { db.Entry(faultRecoveryLog).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProjectID = new SelectList(db.Project, "ProjectID", "Name", faultRecoveryLog.ProjectID); return(View(faultRecoveryLog)); }
public ActionResult Edit([Bind(Include = "FunctionalTestingLogID,ProjectID,Login,Date,TestName,CurrentStateProblemDescription,ProposedSolution,ChangesMadeDuringTest,Observations,RecommendedChanges,ChangeApproved,Hyperlinks,Results")] FunctionalTestingLog functionalTestingLog) { if (ModelState.IsValid) { db.Entry(functionalTestingLog).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProjectID = new SelectList(db.Project, "ProjectID", "Name", functionalTestingLog.ProjectID); return(View(functionalTestingLog)); }
public ActionResult Edit([Bind(Include = "DeficiencyID,ProjectID,TestConditionsAndResults,MissionImpact,CauseAnalysis,RemedialAction")] DeficiencyReport deficiencyReport) { if (ModelState.IsValid) { db.Entry(deficiencyReport).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProjectID = new SelectList(db.Project, "ProjectID", "Name", deficiencyReport.ProjectID); return(View(deficiencyReport)); }
public void DeleteProjectExecutor(int ProjectId, int PersonId) { try { using (ProjectsDB db = new ProjectsDB()) { var executor = db.ProjectExecutors.Where(x => x.ProjectId == ProjectId && x.ProjectExecutorId == PersonId).FirstOrDefault(); if (executor != null) { db.Entry(executor).State = EntityState.Deleted; } db.SaveChanges(); } } catch (Exception ex) { throw new DBException("DeleteProjectExecutor(): ", ex.ToString()); } }
public void UpdateEmployee(EmployeeModel model) { try { using (ProjectsDB db = new ProjectsDB()) { var employee = db.Staff.Where(s => s.PersonId == model.PersonId).FirstOrDefault(); employee.FirstName = model.FirstName; employee.Patronymic = model.Patronymic; employee.LastName = model.LastName; employee.Email = model.Email; db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); } } catch (Exception ex) { throw new DBException("UpdateEmployee(): ", ex.ToString()); } }
public void UpdateProject(ProjectModel model) { try { using (ProjectsDB db = new ProjectsDB()) { var project = db.ProjectInfo.Where(p => p.ProjectId == model.ProjectId).FirstOrDefault(); project.ClientCompanyName = model.ClientCompanyName; project.ExecutiveCompanyName = model.ExecutiveCompanyName; project.Priority = model.Priority; project.StartDate = model.StartDate; project.EndDate = model.EndDate; project.Comment = model.Comment; project.ProjectManagerId = model.ProjectManagerId; db.Entry(project).State = EntityState.Modified; db.SaveChanges(); } } catch (Exception ex) { throw new DBException("UpdateProject(): ", ex.ToString()); } }