public void Handle(AddUpdateVehicleType command) { var company = _repository.Get(command.CompanyId); company.AddUpdateVehicleType(command.VehicleTypeId, command.Name, command.LogoName, command.ReferenceDataVehicleId, command.MaxNumberPassengers, command.ReferenceNetworkVehicleTypeId, command.IsWheelchairAccessible); _repository.Save(company, command.Id.ToString()); }
public object Put(VehicleTypeRequest request) { var existing = _dao.FindById(request.Id); if (existing == null) { throw new HttpError(HttpStatusCode.NotFound, "Vehicle Type Not Found"); } var command = new AddUpdateVehicleType { VehicleTypeId = request.Id, Name = request.Name, LogoName = request.LogoName, ReferenceDataVehicleId = request.ReferenceDataVehicleId, CompanyId = AppConstants.CompanyId, MaxNumberPassengers = request.MaxNumberPassengers, ReferenceNetworkVehicleTypeId = request.ReferenceNetworkVehicleTypeId, IsWheelchairAccessible = request.IsWheelchairAccessible }; _commandBus.Send(command); if (_serverSettings.ServerData.Network.Enabled) { _taxiHailNetworkServiceClient.UpdateMarketVehicleType(_serverSettings.ServerData.TaxiHail.ApplicationKey, new CompanyVehicleType { Id = command.VehicleTypeId, LogoName = command.LogoName, MaxNumberPassengers = command.MaxNumberPassengers, Name = command.Name, ReferenceDataVehicleId = command.ReferenceDataVehicleId, NetworkVehicleId = command.ReferenceNetworkVehicleTypeId }) .HandleErrors(); } return(new { Id = command.VehicleTypeId }); }
public void when_adding_vehicletype_successfully() { var command = new AddUpdateVehicleType { CompanyId = _companyId, VehicleTypeId = Guid.NewGuid(), Name = "Taxi", LogoName = "Taxi", ReferenceDataVehicleId = 123, MaxNumberPassengers = 2 }; _sut.When(command); var evt = _sut.ThenHasSingle <VehicleTypeAddedUpdated>(); Assert.AreEqual(_companyId, evt.SourceId); Assert.AreEqual(command.Name, evt.Name); Assert.AreEqual(command.LogoName, evt.LogoName); Assert.AreEqual(command.VehicleTypeId, evt.VehicleTypeId); Assert.AreEqual(command.ReferenceDataVehicleId, evt.ReferenceDataVehicleId); Assert.AreEqual(command.MaxNumberPassengers, evt.MaxNumberPassengers); }
public object Post(VehicleTypeRequest request) { var command = new AddUpdateVehicleType { VehicleTypeId = Guid.NewGuid(), Name = request.Name, LogoName = request.LogoName, ReferenceDataVehicleId = request.ReferenceDataVehicleId, CompanyId = AppConstants.CompanyId, MaxNumberPassengers = request.MaxNumberPassengers, ReferenceNetworkVehicleTypeId = request.ReferenceNetworkVehicleTypeId, IsWheelchairAccessible = request.IsWheelchairAccessible }; if (_serverSettings.ServerData.Network.Enabled) { _taxiHailNetworkServiceClient.UpdateMarketVehicleType(_serverSettings.ServerData.TaxiHail.ApplicationKey, new CompanyVehicleType { Id = command.VehicleTypeId, LogoName = command.LogoName, MaxNumberPassengers = command.MaxNumberPassengers, Name = command.Name, ReferenceDataVehicleId = command.ReferenceDataVehicleId, NetworkVehicleId = command.ReferenceNetworkVehicleTypeId }) .HandleErrors(); } _commandBus.Send(command); return(new { Id = command.VehicleTypeId }); }