public async Task <string> AddDeliveryDemand(DeliveryDemand deliveryDemand) { using IDbConnection connection = _sqlConnectionFactory.CreateConnection(); connection.Open(); var sql = new QueryBuilder().InsertInto(DeliveryDemandEntity.TableName, DeliveryDemandsTableColumns).Build(); var deliveryDemandEntity = ToDeliveryDemandEntity(deliveryDemand); await connection.ExecuteAsync(sql, deliveryDemandEntity); return(deliveryDemand.Id); }
public async Task UpdateDeliveryDemand(DeliveryDemand deliveryDemand) { using IDbConnection connection = _sqlConnectionFactory.CreateConnection(); connection.Open(); var sql = new QueryBuilder().Update(DeliveryDemandEntity.TableName, DeliveryDemandsTableColumns) .Where($"Id = @Id").Build(); int rowsAffected = await connection.ExecuteAsync(sql, deliveryDemand); if (rowsAffected == 0) { throw new StorageErrorException($"DeliveryDemand entity with Id {deliveryDemand.Id} was not found", 404); } }
private async void DeliveryInfoPanel_FindDeliveryDemandMatch_Click(object sender, EventArgs e) { var timeWindowStart = ToUnixTime(DeliveryInfoPanel_DatePicker.Value, DeliveryInfoPanel_TimePicker1.Value); var timeWindowEnd = ToUnixTime(DeliveryInfoPanel_DatePicker.Value, DeliveryInfoPanel_TimePicker2.Value); var location = new Location { Longitude = Convert.ToDouble(DeliveryInfoPanel_Longitude.Text), Latitude = Convert.ToDouble(DeliveryInfoPanel_Latitude.Text) }; var matchDeliveryDemandRequest = new MatchDeliveryDemandRequest { TimeWindowStart = timeWindowStart, TimeWindowEnd = timeWindowEnd, DelivererLocation = location, TransportationType = transportationType[DeliveryInfoPanel_TransportationType.Text] }; var matchDeliveryDemandResult = await client.MatchDeliveryDemand(matchDeliveryDemandRequest); matchedDeliveryDemand = matchDeliveryDemandResult.DeliveryDemand; ETA = matchDeliveryDemandResult.ETA; Navigate(DeliveryDemandMatchPanel); }
private DeliveryDemandEntity ToDeliveryDemandEntity(DeliveryDemand deliveryDemand) { var entity = _mapper.Map <DeliveryDemandEntity>(deliveryDemand); return(entity); }