public ActionResult AddEditEmployeeToProject(EmployeeToProjectEntity employeeEntity) { if (ModelState.IsValid) { _employeeModelFactory.AddEditEmployeeToProjectFactory(employeeEntity); return(RedirectToAction("EmployeeToProjectIndex")); } return(View()); }
public void UpdateEmployeeToProject(EmployeeToProjectEntity employeeToProjectEntity) { EmployeeToProject employeeToProject = new EmployeeToProject(); employeeToProject.Id = employeeToProjectEntity.Id; employeeToProject.EmpId = employeeToProjectEntity.EmpId; employeeToProject.ProjectId = employeeToProjectEntity.ProjectId; _repositoryEmployeeToProject.Update(employeeToProject); _repositoryEmployeeToProject.SaveChanges(); }
public void AddEditEmployeeToProjectFactory(EmployeeToProjectEntity employeeToProjectEntity) { if (employeeToProjectEntity.Id > 0) { employeeService.UpdateEmployeeToProject(employeeToProjectEntity); } else { employeeService.InsertEmployeeToProject(employeeToProjectEntity); } }
public EmployeeToProjectEntity PrepareEmployeeToProjectModelById(int id) { var employeetoProjectEntity = new EmployeeToProjectEntity(); var emptoProj = employeeService.GetEmployeeToProjectById(id); if (emptoProj != null) { employeetoProjectEntity.Id = emptoProj.Id; employeetoProjectEntity.EmpId = emptoProj.EmpId ?? 0; employeetoProjectEntity.ProjectId = emptoProj.ProjectId ?? 0; } return(employeetoProjectEntity); }
public void InsertEmployeeToProject(EmployeeToProjectEntity employeeToProjectEntity) { EmployeeToProject employeeToProject = new EmployeeToProject(); employeeToProject.Id = employeeToProjectEntity.Id; employeeToProject.EmpId = employeeToProjectEntity.EmpId; employeeToProject.ProjectId = employeeToProjectEntity.ProjectId; if (!_repositoryEmployeeToProject.Table.Any(x => x.ProjectId == employeeToProject.ProjectId && x.EmpId == employeeToProject.EmpId)) { _repositoryEmployeeToProject.Insert(employeeToProject); _repositoryEmployeeToProject.SaveChanges(); } }
public ActionResult AddEditEmployeeToProject(int Id = 0) { var EmpList = _employeeModelFactory.PrepareEmployeeList(); ViewBag.Employees = new SelectList(EmpList, "Id", "FullName") { }; var ProjectList = _projectModelFactory.PrepareProjectList(); ViewBag.Projects = new SelectList(ProjectList, "Id", "Name") { }; EmployeeToProjectEntity employeeEntity = new EmployeeToProjectEntity(); if (Id > 0) { employeeEntity = _employeeModelFactory.PrepareEmployeeToProjectModelById(Id); } return(View(employeeEntity)); }