//TODO: test logic maybe is wrong to asign multiple insurance

        /* Check vehicleId
         * Expired
         * TypeOfInsurance
         * maybe and compare date with type insurance
         */
        private async Task <bool> ExistTypeOfInsurancePolicyOnVehicle(int vehicleId, TypeInsurance insuranceType)
        {
            var isExpire = await this.db.InsurancePolicies
                           .AnyAsync(i =>
                                     i.VehicleId == vehicleId &&
                                     i.EndDate >= DateTime.UtcNow &&
                                     i.TypeInsurance == insuranceType &&
                                     !i.Expired &&
                                     i.TypeInsurance == insuranceType);

            return(isExpire);
        }
        public async Task AddPolicyAsyncShouldReturnErrorIfVehicleHasActiveInsurance(TypeInsurance typeInsurance)
        {
            //Arrange

            var model = new InsurancePolicyFormServiceModel
            {
                StartDate          = DateTime.UtcNow,
                EndDate            = DateTime.Parse("2022-01-01 00:00:00.0000000"),
                InsuranceCompanyId = 2,
                TypeInsurance      = typeInsurance
            };

            //Act
            var exceptionMessage = await Assert.ThrowsAsync <ArgumentException>(()
                                                                                => this.insuranceServices.AddPolicyAsync(1, model));

            //Assert
            Assert.Equal(ExistItemExceptionMessage, exceptionMessage.Message);
        }
 public void UpdateTypeInsurance(TypeInsurance priceList)
 {
 }
 public void DeleteTypeInsurance(TypeInsurance priceList)
 {
     _context.TypeInsurance.Remove(priceList);
 }
 public void AddTypeInsurance(TypeInsurance typeInsurance)
 {
     _context.TypeInsurance.Add(typeInsurance);
 }
Beispiel #6
0
 public void UpdateTypeInsurance(TypeInsurance typeInsurance)
 {
     _typeInsuranceRepository.UpdateTypeInsurance(typeInsurance);
 }
Beispiel #7
0
 public void DeleteTypeInsurance(TypeInsurance typeInsurance)
 {
     _typeInsuranceRepository.DeleteTypeInsurance(typeInsurance);
 }
Beispiel #8
0
 public void AddTypeInsurance(TypeInsurance typeInsurance)
 {
     _typeInsuranceRepository.AddTypeInsurance(typeInsurance);
 }
Beispiel #9
0
 public Insurance(int id, TypeInsurance type)
 {
     this.Type        = type;
     this.InsuranceId = id;
 }
Beispiel #10
0
 public Insurance(TypeInsurance type)
 {
     this.Type = type;
 }
 public async Task Update(TypeInsurance insurance, int id)
 {
     await _unitOfWork.TypeInsuranceRepository.Update(insurance, id);
 }
 public async Task Create(TypeInsurance insurance)
 {
     await _unitOfWork.TypeInsuranceRepository.Create(insurance);
 }