private void Btn2_Click(object sender, RoutedEventArgs e) { Price.GetBindingExpression(NumericUpDown.ValueProperty).UpdateSource(); OldDebt.GetBindingExpression(NumericUpDown.ValueProperty).UpdateSource(); TransportCost.GetBindingExpression(NumericUpDown.ValueProperty).UpdateSource(); Paid.GetBindingExpression(NumericUpDown.ValueProperty).UpdateSource(); }
public IActionResult Post(string orderID, [FromBody] DeliveryViewModel order) { try { if (ModelState.IsValid) { var entityOrderID = this._cxt.Orders .Where(o => o.CustomerID.Equals(orderID)) .FirstOrDefault().ID; var entityDeliveryArea = this._cxt.DeliveryAreas .Where(d => d.Region.Contains(order.Region) && d.District.Contains(order.District)) .FirstOrDefault(); var entityTranspostCost = new TransportCost(); if (order.Weight < 500) { entityTranspostCost = this._cxt.TransportCost.Where(o => o.Payload == 500).FirstOrDefault(); } else if (order.Weight > 500 && order.Weight < 1000) { entityTranspostCost = this._cxt.TransportCost.Where(o => o.Payload == 1000).FirstOrDefault(); } else { entityTranspostCost = this._cxt.TransportCost.Where(o => o.Payload == 2000).FirstOrDefault(); } this._cxt.Deliveries.Add(new Delivery { OrderID = entityOrderID, TransportCostID = entityTranspostCost.ID, DeliveryAreaID = entityDeliveryArea.ID, Weight = order.Weight, DeliveryCost = order.cost, }); if (this._cxt.SaveChanges() > 0) { var d = new CustomerDeliveryView(); d.Region = order.Region; d.District = order.District; d.DeliveryCost = order.cost; d.Weight = order.Weight; return(Created($"api/Delivery/{orderID}", d)); } else { return(BadRequest("You Order Could not be saved")); } } else { return(BadRequest("You Order Could not be saved")); } } catch (Exception ex) { return(BadRequest(ex)); } }