Example #1
0
        PositionDTO IPositionsService.AddPosition(PositionDTO newPosition)
        {
            Position addedPosition = _unitOfWork.Positions.Create(_mapper.Map <Position>(newPosition));

            _unitOfWork.Save();
            return(_mapper.Map <PositionDTO>(addedPosition));
        }
        WorkTaskDTO IWorkTasksService.AddWorkTask(WorkTaskDTO newTask, string performerId)
        {
            IEnumerable <Position> performerPosition = _unitOfWork.Positions.Filter(p => p.IdProject == newTask.IdProject && p.IdUser == performerId);

            Position assignPosition;

            if (performerPosition.Count() == 0)
            {
                assignPosition = _unitOfWork.Positions.Create(new Position {
                    IdProject = newTask.IdProject, IdUser = performerId, Name = "performer"
                });
                _unitOfWork.Save();
            }
            else
            {
                assignPosition = performerPosition.First();
            }

            newTask.StartDate   = DateTime.Now;
            newTask.IdPerformer = assignPosition.Id;
            var addedTask = _unitOfWork.WorkTasks.Create(_mapper.Map <WorkTask>(newTask));

            _unitOfWork.Save();
            return(_mapper.Map <WorkTaskDTO>(addedTask));
        }
Example #3
0
        public void AddDataDetails(DataDetails dataDetails)
        {
            if (dataDetails == null || string.IsNullOrWhiteSpace(dataDetails.FileName))
            {
                throw new InvalidOperationException("Data File name is missing");
            }

            _dataUnitOfWork.DataDetailsRepository.Add(dataDetails);
            _dataUnitOfWork.Save();
        }
        ProjectDTO IProjectsService.AddProject(ProjectDTO newProject, string creatorId)
        {
            var projectToAdd = _mapper.Map <Project>(newProject);

            projectToAdd.StartDate = DateTime.Now;

            Project addedProject = _unitOfWork.Projects.Create(projectToAdd);

            _unitOfWork.Save();

            _unitOfWork.Positions.Create(new Position {
                IdProject = addedProject.Id, IdUser = creatorId, Name = "creator"
            });
            _unitOfWork.Save();

            return(_mapper.Map <ProjectDTO>(addedProject));
        }