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); }
public ActionResult Create(FormCollection collection) { try { OrderChartModels orderchartModel = new OrderChartModels(); UpdateModel(orderchartModel); orderchartModel.Date = DateTime.UtcNow; orderchartModel.TotalPrice = shoppingCartRepository.TotalPrice(); orderchartModel.ShoppingCartID = shoppingCartRepository.LastShoppingCartOrderID(); orderchartModel.ClientID = new Guid(); orderChartRepository.InsertOrderChart(orderchartModel); return(RedirectToAction("Index")); } catch { return(View("CreateOrderChart")); } }
public void InsertOrderChart(OrderChartModels orderChartModels) { dbContext.OrderCharts.InsertOnSubmit(MapModelToDbObject(orderChartModels)); dbContext.SubmitChanges(); }