public int LastOrder() { OrderChart orderChart = dbContext.OrderCharts.OrderByDescending(x => x.OrderChartID).FirstOrDefault(); if (orderChart != null) { return(MapDbObjectsToModel(orderChart).OrderChartID + 1); } return(1); }
public void DeleteOrderChart(int id) { OrderChart dbOrderChart = dbContext.OrderCharts.FirstOrDefault(x => x.OrderChartID == id); if (dbOrderChart != null) { dbContext.OrderCharts.DeleteOnSubmit(dbOrderChart); dbContext.SubmitChanges(); } }
public void UpdateOrderChart(OrderChartModels orderchart) { OrderChart dbOrderChart = dbContext.OrderCharts.FirstOrDefault(x => x.OrderChartID == orderchart.OrderChartID); if (dbOrderChart != null) { dbOrderChart.OrderChartID = orderchart.OrderChartID; dbOrderChart.ShoppingCartID = orderchart.ShoppingCartID; dbOrderChart.Date = orderchart.Date; dbOrderChart.ClientID = orderchart.ClientID; dbOrderChart.TotalPrice = orderchart.TotalPrice; dbOrderChart.DeliveryAdress = orderchart.DeliveryAdress; dbContext.SubmitChanges(); } }
private OrderChart MapModelToDbObject(OrderChartModels orderchart) { OrderChart dbOrderChart = new OrderChart(); if (orderchart != null) { dbOrderChart.OrderChartID = orderchart.OrderChartID; dbOrderChart.ShoppingCartID = orderchart.ShoppingCartID; dbOrderChart.Date = orderchart.Date; dbOrderChart.ClientID = orderchart.ClientID; dbOrderChart.TotalPrice = orderchart.TotalPrice; dbOrderChart.DeliveryAdress = orderchart.DeliveryAdress; return(dbOrderChart); } return(null); }
private OrderChartModels MapDbObjectsToModel(OrderChart dbOrderChart) { OrderChartModels OrderChartModels = new OrderChartModels(); if (dbOrderChart != null) { OrderChartModels.OrderChartID = dbOrderChart.OrderChartID; OrderChartModels.ShoppingCartID = dbOrderChart.ShoppingCartID; OrderChartModels.Date = dbOrderChart.Date; OrderChartModels.ClientID = dbOrderChart.ClientID; OrderChartModels.TotalPrice = dbOrderChart.TotalPrice; OrderChartModels.DeliveryAdress = dbOrderChart.DeliveryAdress; return(OrderChartModels); } return(null); }