public ActionResult Update(ProjectSectionDepartment projectSectionDepartment)
        {
            var result = _projectSectionDepartmentService.Update(projectSectionDepartment);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Пример #2
0
        public IResult Update(ProjectSectionDepartment projectSectionDepartment)
        {
            IResult result = BusinessRules.Run(CheckIfDepartmentAlreadyExistInSection(projectSectionDepartment));

            if (result != null)
            {
                return(result);
            }
            _projectSectionDepartmentDal.Update(projectSectionDepartment);
            return(new SuccessResult(Messages.ProjectSectionDepartmentUpdate));
        }
Пример #3
0
        //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));
        }
Пример #5
0
 public IResult Delete(ProjectSectionDepartment projectSectionDepartment)
 {
     projectSectionDepartment.Status = false;
     _projectSectionDepartmentDal.Update(projectSectionDepartment);
     return(new SuccessResult(Messages.ProjectSectionDepartmentDeleted));
 }