Beispiel #1
0
        public void NotConvertBO_WithNull()
        {
            ContractBO bo     = null;
            var        entity = _converter.Convert(bo);

            Assert.Null(entity);
        }
        public ProblemController(ProblemsManager problemsManager, FileManager fileManager,
                                 ContractBO contractBo)
        {
            _problemsManager = problemsManager;
            _fileManager     = fileManager;

            _contractBo = contractBo;
        }
Beispiel #3
0
 public ContractBO Create(ContractBO bo)
 {
     using (var unitOfWork = _uow)
     {
         var convertedEntity = _converter.Convert(bo);
         var createdEntity   = unitOfWork.ContractRepository.Create(convertedEntity);
         unitOfWork.Complete();
         return(_converter.Convert(createdEntity));
     }
 }
Beispiel #4
0
 public ContractBO Update(ContractBO bo)
 {
     using (var unitOfWork = _uow)
     {
         var contractFromDB = unitOfWork.ContractRepository.Get(bo.ProjectId, bo.GroupId, bo.CompanyId);
         if (contractFromDB == null)
         {
             return(null);
         }
         contractFromDB.AdminApproved      = bo.AdminApproved;
         contractFromDB.SupervisorApproved = bo.SupervisorApproved;
         unitOfWork.Complete();
         return(_converter.Convert(contractFromDB));
     }
 }
Beispiel #5
0
        public IActionResult Post([FromBody] ContractBO value)
        {
            if (value == null)
            {
                return(new BadRequestObjectResult(ErrorMessages.InvalidEntityString));
            }
            var result = _service.Create(value);

            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(ModelState));
            }
            if (value.ProjectId != 0)
            {
                return(new OkObjectResult(result));
            }

            var project = _projectService.Create(new ProjectBO());

            value.ProjectId = project.Id;
            return(new OkObjectResult(result));
        }
Beispiel #6
0
        public IActionResult Put(int projectId, int groupId, int companyId, [FromBody] ContractBO value)
        {
            if (value == null)
            {
                return(new BadRequestObjectResult(ErrorMessages.InvalidEntityString));
            }
            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(ModelState));
            }
            if (projectId != value.ProjectId ||
                groupId != value.GroupId ||
                companyId != value.CompanyId)
            {
                return(new BadRequestObjectResult(ErrorMessages.MismatchingIdString));
            }
            var result = _service.Update(value);

            if (result == null)
            {
                return(new NotFoundObjectResult(ErrorMessages.NotFoundString));
            }
            return(new OkObjectResult(result));
        }
Beispiel #7
0
        public UserController(UserManager userManager, ContractBO contractBo)
        {
            _userManager = userManager;

            _contractBo = contractBo;
        }