Beispiel #1
0
        public bool SetContractorForRequest(out string error, int contractorId, int requestId, string comment)
        {
            error = "";

            var request    = _requestRepository.GetById(requestId);
            var contractor = _contractorRepository.GetById(contractorId);

            if (request == null)
            {
                error = "Ошибка: Заявка не найдена";
                return(false);
            }

            if (contractor == null)
            {
                error = "Ошибка: Подрядчик не найден";
                return(false);
            }


            request.StatusId = (int)Statuses.WasAccepted;
            request.Price    = contractor.Tariff * (decimal)request.Mileage;
            request.Comment  = comment;

            _requestRepository.Update(request);

            return(true);
        }
Beispiel #2
0
        //[Fact]
        public void Delete_Passes_Correct_Contractor_To_View()
        {
            var contractorId       = 42;
            var expectedContractor = new Contractor();

            contractorRepo.GetById(contractorId).Returns(expectedContractor);

            var result = underTest.Delete(contractorId);
            var model  = ((ViewResult)result).Model;

            Assert.Same(expectedContractor, model);
        }
        /// <summary>
        /// Получение контрагента по id с проверкой его существования
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Contractor CheckContractorExistence(int id, string message = "")
        {
            var contractor = contractorRepository.GetById(id);

            ValidationUtils.NotNull(contractor, String.IsNullOrEmpty(message) ? "Контрагент не найден. Возможно, он был удален." : message);

            return(contractor);
        }
        public ContractorResumeQuery GetContractorResume(int id)
        {
            var entity = _ContractorRepository.GetById(id);

            return(new ContractorResumeQuery
            {
                Id = entity.Id,
                Nome = entity.Name
            });
        }
 public IActionResult Get(int id)
 {
     try
     {
         var contractor = contractorRepository.GetById(id);
         return(new OkObjectResult(contractor));
     }
     catch (Exception ex)
     {
         LogInfo.LogMessage(enumLogInfoType.Error, ex);
         return(new BadRequestObjectResult(ex));
     }
 }
Beispiel #6
0
        public IActionResult Delete(int id)
        {
            var model = contractorRepo.GetById(id);

            return(View(model));
        }
        public ContractorModel GetById(Guid id)
        {
            var contractor = _repository.GetById(id);

            return(contractor?.GetModel());
        }
Beispiel #8
0
 public Contractor GetById(Guid id)
 {
     return(_repository.GetById(id));
 }