public async Task Handle(VehicleStatusChangedIntegrationEvent @event)
 {
     try
     {
         var newActivity = new VehicleActivityDTO(@event.VehicleId, @event.Status);
         await _uow.SaveVehicleActivityTransactionAsync(newActivity);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 public void SaveVehicleActivityTransaction(VehicleActivityDTO vehicleActivityDTO)
 {
     try
     {
         VehicleActivityRepo.Add(vehicleActivityDTO.GetDALObj());
         Commit();
     }
     catch (Exception ex)
     {
         _logger.LogCritical(ex.Message);
         throw ex;
     }
 }
Ejemplo n.º 3
0
        public async Task <bool> SaveVehicleActivityTransactionAsync(VehicleActivityDTO vehicleActivityDTO)
        {
            try
            {
                VehicleActivityRepo.Add(vehicleActivityDTO.GetDALObj());
                await CommitAsync();

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 4
0
        public void SaveVehicleActivityTransaction_ShouldAddNewActivity()
        {
            // Arrange
            var testVehicleActivity = new VehicleActivityDTO()
            {
                VehicleId = "YS2R4X20005399401", Status = false, EntryDate = DateTime.Now
            };

            _mockVehicleActivitiesRepo.Setup(rep => rep.Add(testVehicleActivity.GetDALObj())).Returns(testVehicleActivity.GetDALObj());
            _mockVehicleActivitiesRepo.Setup(rep => rep.SaveChangesAsync()).Returns(() => Task <int> .Run(() => { return(1); }));
            _mockRepositoryProvider.Setup(rep => rep.GetRepositoryForEntityType <VehicleActivity>()).Returns(_mockVehicleActivitiesRepo.Object);

            _vehicleServiceUow = new VehicleActivityServiceUOW(_mockRepositoryProvider.Object, _mockLogger);

            // Act
            try
            {
                _vehicleServiceUow.SaveVehicleActivityTransaction(testVehicleActivity);
            }
            catch (Exception ex)
            {
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }
        }