Пример #1
0
        public async Task <int> CreateInsurance(ViewModel.CreateInsuranceRequest insuranceRequest)
        {
            var insuranceViewModel = _mapper.Map <ViewModel.Insurance>(insuranceRequest);
            var domainInsurance    = _mapper.Map <Domain.Insurance.Model.Insurance>(insuranceViewModel);
            var result             = await _insuranceRepository.AddInsuranceAsync(domainInsurance);

            await _insuranceRepository.UnitOfWork.SaveEntitiesAsync();

            return(result);
        }
        public async Task <IActionResult> PostAsync(Transfer_Insurance insurance)
        {
            _logger.LogInformation($"Adding new insurance.");
            Inner_Insurance transformedInsurance = new Inner_Insurance
            {
                InsuranceId   = 0,
                InsuranceName = insurance.InsuranceName
            };
            await _insuranceRepository.AddInsuranceAsync(transformedInsurance);

            return(CreatedAtAction(nameof(GetByIdAsync), new { id = insurance.InsuranceId }, insurance));
        }