public object Delete(VehicleTypeRequest request) { var existing = _dao.FindById(request.Id); if (existing == null) { throw new HttpError(HttpStatusCode.NotFound, "Vehicle Type Not Found"); } var command = new DeleteVehicleType { VehicleTypeId = existing.Id, CompanyId = AppConstants.CompanyId }; _commandBus.Send(command); if (_serverSettings.ServerData.Network.Enabled) { _taxiHailNetworkServiceClient.DeleteMarketVehicleMapping(_serverSettings.ServerData.TaxiHail.ApplicationKey, request.Id) .HandleErrors(); } return(new HttpResult(HttpStatusCode.OK, "OK")); }
public void Handle(DeleteVehicleType command) { var company = _repository.Get(command.CompanyId); company.DeleteVehicleType(command.VehicleTypeId); _repository.Save(company, command.Id.ToString()); }
public void when_deleting_vehicletype_successfully() { var command = new DeleteVehicleType { CompanyId = _companyId, VehicleTypeId = Guid.NewGuid() }; _sut.When(command); var evt = _sut.ThenHasSingle <VehicleTypeDeleted>(); Assert.AreEqual(_companyId, evt.SourceId); Assert.AreEqual(command.VehicleTypeId, evt.VehicleTypeId); }