public ActionResult Update(ProjectSectionDepartment projectSectionDepartment) { var result = _projectSectionDepartmentService.Update(projectSectionDepartment); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public IResult Update(ProjectSectionDepartment projectSectionDepartment) { IResult result = BusinessRules.Run(CheckIfDepartmentAlreadyExistInSection(projectSectionDepartment)); if (result != null) { return(result); } _projectSectionDepartmentDal.Update(projectSectionDepartment); return(new SuccessResult(Messages.ProjectSectionDepartmentUpdate)); }
//public IDataResult<List<ProjectSectionDepartmentDto>> GetByUserID(int userID) //{ // return new SuccessDataResult<List<ProjectSectionDepartmentDto>>(_projectSectionDepartmentDal.GetByUserID(userID)); //} private IResult CheckIfDepartmentAlreadyExistInSection(ProjectSectionDepartment projectSectionDepartment) { var result = _projectSectionDepartmentDal.GetAll(p => p.ProjectSectionID == projectSectionDepartment.ProjectSectionID).Find(p => p.DepartmentTypeID == projectSectionDepartment.DepartmentTypeID); if (result != null) { if (result.ProjectSectionDepartmentID != projectSectionDepartment.ProjectSectionDepartmentID) { return(new ErrorResult(Messages.DepartmentAlreadyExistInSection)); } } return(new SuccessResult()); }
public IResult Add(ProjectCreationDto projectCreationDto) { var project = _mapper.Map <ProjectCreationDto, Project>(projectCreationDto); project.ActiveWorkerCount = 0; project.RemainingProjectTime = project.TotalDeclaredTime; project.Status = true; _projectService.Add(project); foreach (var projectSection in projectCreationDto.ProjectSections) { var psection = new ProjectSection { ProjectID = project.ProjectID, ProjectSectionName = projectSection.ProjectSectionName, SectionProjectTime = projectSection.SectionProjectTime, }; _projectSectionService.Add(psection); foreach (var projectSectionDepartment in projectSection.ProjectSectionDepartment) { var psDepartment = new ProjectSectionDepartment { ProjectSectionID = psection.ProjectSectionID, DepartmentTypeID = projectSectionDepartment.DepartmentTypeID, Status = true }; _projectSectionDepartmentService.Add(psDepartment); } } return(new SuccessResult(Messages.ProjectAdded)); }
public IResult Delete(ProjectSectionDepartment projectSectionDepartment) { projectSectionDepartment.Status = false; _projectSectionDepartmentDal.Update(projectSectionDepartment); return(new SuccessResult(Messages.ProjectSectionDepartmentDeleted)); }