public static bool MarkOrderMoneyOutFinished(string orderId) { bool success = false; try { using (var db = new OrderMoneyOutContext()) { var order = db.Orders.FirstOrDefault(p => p.OrderId == orderId); if (order != null) { order.Status = StatusOrder.Finished; order.ExecutionDate = DateTime.Now; db.SaveChanges(); success = true; } } } catch (Exception e) { success = false; } return(success); }
public static void UpdateOrderMoneyOutFinished(List <OrderMoneyOut> data) { try { var ids = data.Select(p => p.OrderId); using (var db = new OrderMoneyOutContext()) { var orders = db.Orders.Where(p => ids.Contains(p.OrderId)); foreach (var item in data) { var order = orders.FirstOrDefault(p => p.OrderId == item.OrderId); if (order != null) { order.AmountOut = item.AmountOut; } } if (orders != null) { db.SaveChanges(); } } } catch (Exception e) { } }
public static bool AddNewOrderMoneyOut(OrderMoneyOut order) { var success = false; try { using (var db = new OrderMoneyOutContext()) { db.Orders.Add(order); db.SaveChanges(); success = true; } } catch (Exception e) { success = false; } return(success); }