public static void Run([HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "Company/{id}")] HttpRequest req, string id, TraceWriter log) { log.Info("C# HTTP trigger function processed DeleteCompany."); if (_dataAccessRead.GetCompany(new Guid(id)) == null) { return; } var companyId = new Guid(id); var cars = _dataAccessRead.GetCars().Where(c => c.CompanyId == companyId); foreach (var car in cars) { var deleteCar = new DeleteCar() { CarId = car.CarId, CompanyId = car.CompanyId, DeleteCarTimeStamp = DateTime.Now.Ticks }; _endpointInstance.Send(Helpers.ServerEndpoint, deleteCar).ConfigureAwait(false); } var message = new Shared.Messages.Commands.DeleteCompany { DataId = new Guid(), CompanyId = companyId, DeleteCompanyTimeStamp = DateTime.Now.Ticks }; _endpointInstance.Send(Helpers.ServerEndpoint, message).ConfigureAwait(false); }
public async Task DeleteCompany(string id) { if (GetCompany(id) == null) { return; } var companyId = new Guid(id); var cars = _dataAccessRead.GetCars().Where(c => c.CompanyId == companyId); foreach (var car in cars) { var deleteCar = new DeleteCar() { CarId = car.CarId, CompanyId = car.CompanyId, DeleteCarTimeStamp = DateTime.Now.Ticks }; await _endpointInstance.Send(Helpers.ServerEndpoint, deleteCar).ConfigureAwait(false); } var message = new DeleteCompany { DataId = new Guid(), CompanyId = companyId, DeleteCompanyTimeStamp = DateTime.Now.Ticks }; await _endpointInstance.Send(Helpers.ServerEndpoint, message).ConfigureAwait(false); }
public async Task <IEnumerable <CarRead> > GetCars() { var list = new List <CarRead>(); var cars = _dataAccess.GetCars(); foreach (var car in cars) { if (car.Locked) { if (CarHasBeenLocked40Seconds(car)) { //Lock timed out and can be ignored and set to false var updateCarLockedStatus = new UpdateCarLockedStatus { LockedStatus = false, CarId = car.CarId, CompanyId = car.CompanyId, UpdateCarLockedTimeStamp = DateTime.Now.Ticks }; await _endpointInstancePriority.Publish(updateCarLockedStatus).ConfigureAwait(false); } } list.Add(new CarRead(car.CarId) { CompanyId = car.CompanyId, CreationTime = car.CreationTime, Locked = car.Locked, Online = car.Online, Speed = car.Speed, RegNr = car.RegNr, VIN = car.VIN }); } return(list); }