public static void Run([HttpTrigger(AuthorizationLevel.Anonymous, "put", Route = "Company")] HttpRequest req, TraceWriter log) { log.Info("C# HTTP trigger function processed UpdateCompany."); //string company = req.Query["company"]; string requestBody = new StreamReader(req.Body).ReadToEnd(); dynamic data = JsonConvert.DeserializeObject(requestBody); var company = (CompanyRead)data?.company; var oldCompany = _dataAccessRead.GetCompany(company.CompanyId); if (oldCompany == null) { return; } var message = new UpdateCompanyName { DataId = new Guid(), CompanyId = company.CompanyId, Name = company.Name, UpdateCompanyNameTimeStamp = DateTime.Now.Ticks }; _endpointInstance.Send(Helpers.ServerEndpoint, message).ConfigureAwait(false); }
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 CompanyRead GetCompany(string id) { return(_dataAccessRead.GetCompany(new Guid(id))); }
public static CompanyRead Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "Company/{id}")] HttpRequest req, string id, TraceWriter log) { log.Info("C# HTTP trigger function processed GetCompanyById."); return(_dataAccessRead.GetCompany(new Guid(id))); }