public IActionResult GetTotal([FromBody] EDeliveryConfirmOrder eDeliveryConfirmOrder) { Decimal total = 0; foreach (EDeliveryProductInBasket eProduct in eDeliveryConfirmOrder.productList) { if (eProduct.option1Price.HasValue) { total += eProduct.quantity * eProduct.option1Price.Value; } else if (eProduct.unitPrice.HasValue) { total += eProduct.unitPrice.Value; } if (eProduct.addon1Price.HasValue) { total += eProduct.addon1Price.Value; } if (eProduct.addon2Price.HasValue) { total += eProduct.addon2Price.Value; } if (eProduct.addon3Price.HasValue) { total += eProduct.addon3Price.Value; } } return(Ok(total)); }
static public bool ConfirmOrder(EDeliveryConfirmOrder eDeliveryConfirmOrder) { try { using var context = new SMySQLContext(); EDeliveryOrder e = new EDeliveryOrder(); e.companyID = eDeliveryConfirmOrder.companyID; e.visualID = GetNextVisualID(e.companyID); e.entityID = eDeliveryConfirmOrder.userID; e.paymentMethodType = eDeliveryConfirmOrder.paymentMethodType; e.total = eDeliveryConfirmOrder.total; e.creationDateUTC = e.modificationDateUTC = DateTime.UtcNow; if (eDeliveryConfirmOrder.creationDateLocal == null) { e.creationDateLocal = DateTime.UtcNow; } else { e.creationDateLocal = eDeliveryConfirmOrder.creationDateLocal; } e.notes = eDeliveryConfirmOrder.comments; e.status = DeliveryStatus.PendingApproval; e.content = JsonConvert.SerializeObject(eDeliveryConfirmOrder.productList); e.changeFor = eDeliveryConfirmOrder.changeFor; var result = context.DeliveryOrders.Add(e); context.SaveChanges(); return(true); } catch (Exception e) { SLogger.LogError(e); } return(false); }
public IActionResult ConfirmOrder([FromBody] EDeliveryConfirmOrder eDeliveryConfirmOrder) { return(Ok(SDeliveryOrders.ConfirmOrder(eDeliveryConfirmOrder))); }