Exemplo n.º 1
0
        public int LastOrder()
        {
            OrderChart orderChart = dbContext.OrderCharts.OrderByDescending(x => x.OrderChartID).FirstOrDefault();

            if (orderChart != null)
            {
                return(MapDbObjectsToModel(orderChart).OrderChartID + 1);
            }
            return(1);
        }
Exemplo n.º 2
0
        public void DeleteOrderChart(int id)
        {
            OrderChart dbOrderChart = dbContext.OrderCharts.FirstOrDefault(x => x.OrderChartID == id);

            if (dbOrderChart != null)
            {
                dbContext.OrderCharts.DeleteOnSubmit(dbOrderChart);
                dbContext.SubmitChanges();
            }
        }
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }