public List <Order_content> GetOrderContentsByIdOrder(int id_order)
        {
            // khasni n nsift JWT o n checkeh


            return(OrderContentDAO.GetOrderContents(id_order));
        }
        public OrderFullInfo GetClientOrderFullInfoById(int id_order)
        {
            FastFoodEntities db = new FastFoodEntities();

            // khasni n nsift JWT o n checkeh

            TORDER torder = db.TORDERs.FirstOrDefault(o => o.id_order == id_order);


            OrderFullInfo orderFullInfo = new OrderFullInfo();

            if (torder != null)
            {
                orderFullInfo.id_order          = torder.id_order;
                orderFullInfo.order_state       = torder.order_state;
                orderFullInfo.latitude          = torder.latitude;
                orderFullInfo.longitude         = torder.longitude;
                orderFullInfo.order_datetime    = torder.order_datetime;
                orderFullInfo.order_code        = torder.order_code;
                orderFullInfo.delivery_state    = torder.delivery_state;
                orderFullInfo.received_datetime = torder.received_datetime;
                orderFullInfo.id_delivery_man   = torder.id_delivery_man;
                orderFullInfo.id_client         = torder.id_client;
                orderFullInfo.client            = new Client()
                {
                    id_client         = torder.CLIENT.id_client,
                    firstname         = torder.CLIENT.firstname,
                    lastname          = torder.CLIENT.lastname,
                    gender            = torder.CLIENT.gender,
                    email             = torder.CLIENT.email,
                    password          = "",
                    phone             = torder.CLIENT.phone,
                    photo             = torder.CLIENT.photo,
                    confirmation_code = torder.CLIENT.confirmation_code
                };
            }


            if (orderFullInfo.id_delivery_man != null)
            {
                orderFullInfo.delivery_man = DeliveryManDAO.GetDeliveryMan((int)orderFullInfo.id_delivery_man);
            }

            List <Geolocation> geolocations = GeolocationDAO.GetOrderGeolocations(orderFullInfo.id_order);

            if (geolocations != null)
            {
                orderFullInfo.geolocations = geolocations;
            }

            List <Order_content> orderContents = OrderContentDAO.GetOrderContents(orderFullInfo.id_order);

            if (orderContents != null)
            {
                orderFullInfo.order_contents = orderContents;
            }

            return(orderFullInfo);
        }
        public async Task <bool> Delete(OrderContent OrderContent)
        {
            OrderContentDAO OrderContentDAO = await DataContext.OrderContent.Where(x => x.Id == OrderContent.Id).FirstOrDefaultAsync();

            DataContext.OrderContent.Remove(OrderContentDAO);
            await DataContext.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> Update(OrderContent OrderContent)
        {
            OrderContentDAO OrderContentDAO = DataContext.OrderContent.Where(x => x.Id == OrderContent.Id).FirstOrDefault();

            OrderContentDAO.Id            = OrderContent.Id;
            OrderContentDAO.OrderId       = OrderContent.OrderId;
            OrderContentDAO.ItemId        = OrderContent.ItemId;
            OrderContentDAO.ProductName   = OrderContent.ProductName;
            OrderContentDAO.FirstVersion  = OrderContent.FirstVersion;
            OrderContentDAO.SecondVersion = OrderContent.SecondVersion;
            OrderContentDAO.Price         = OrderContent.Price;
            OrderContentDAO.DiscountPrice = OrderContent.DiscountPrice;
            OrderContentDAO.Quantity      = OrderContent.Quantity;
            await DataContext.SaveChangesAsync();

            return(true);
        }
Example #5
0
        public async Task <bool> Create(OrderContent OrderContent)
        {
            OrderContentDAO OrderContentDAO = new OrderContentDAO();

            OrderContentDAO.Id      = OrderContent.Id;
            OrderContentDAO.Code    = OrderContent.Code;
            OrderContentDAO.OrderId = OrderContent.OrderId;
            OrderContentDAO.FoodFoodTypeMappingId = OrderContent.FoodFoodTypeMappingId;
            OrderContentDAO.Quantity = OrderContent.Quantity;
            OrderContentDAO.StatusId = OrderContent.StatusId;
            DataContext.OrderContent.Add(OrderContentDAO);
            await DataContext.SaveChangesAsync();

            OrderContent.Id = OrderContentDAO.Id;
            await SaveReference(OrderContent);

            return(true);
        }
Example #6
0
        public async Task <bool> BulkMerge(List <OrderContent> OrderContents)
        {
            List <OrderContentDAO> OrderContentDAOs = new List <OrderContentDAO>();

            foreach (OrderContent OrderContent in OrderContents)
            {
                OrderContentDAO OrderContentDAO = new OrderContentDAO();
                OrderContentDAO.Id      = OrderContent.Id;
                OrderContentDAO.Code    = OrderContent.Code;
                OrderContentDAO.OrderId = OrderContent.OrderId;
                OrderContentDAO.FoodFoodTypeMappingId = OrderContent.FoodFoodTypeMappingId;
                OrderContentDAO.Quantity = OrderContent.Quantity;
                OrderContentDAO.StatusId = OrderContent.StatusId;
                OrderContentDAOs.Add(OrderContentDAO);
            }
            await DataContext.BulkMergeAsync(OrderContentDAOs);

            return(true);
        }
Example #7
0
        public async Task <bool> Update(OrderContent OrderContent)
        {
            OrderContentDAO OrderContentDAO = DataContext.OrderContent.Where(x => x.Id == OrderContent.Id).FirstOrDefault();

            if (OrderContentDAO == null)
            {
                return(false);
            }
            OrderContentDAO.Id      = OrderContent.Id;
            OrderContentDAO.Code    = OrderContent.Code;
            OrderContentDAO.OrderId = OrderContent.OrderId;
            OrderContentDAO.FoodFoodTypeMappingId = OrderContent.FoodFoodTypeMappingId;
            OrderContentDAO.Quantity = OrderContent.Quantity;
            OrderContentDAO.StatusId = OrderContent.StatusId;
            await DataContext.SaveChangesAsync();

            await SaveReference(OrderContent);

            return(true);
        }
        public async Task <bool> Create(OrderContent OrderContent)
        {
            OrderContentDAO OrderContentDAO = new OrderContentDAO();

            OrderContentDAO.Id            = OrderContent.Id;
            OrderContentDAO.OrderId       = OrderContent.OrderId;
            OrderContentDAO.ItemId        = OrderContent.ItemId;
            OrderContentDAO.ProductName   = OrderContent.ProductName;
            OrderContentDAO.FirstVersion  = OrderContent.FirstVersion;
            OrderContentDAO.SecondVersion = OrderContent.SecondVersion;
            OrderContentDAO.Price         = OrderContent.Price;
            OrderContentDAO.DiscountPrice = OrderContent.DiscountPrice;
            OrderContentDAO.Quantity      = OrderContent.Quantity;

            await DataContext.OrderContent.AddAsync(OrderContentDAO);

            await DataContext.SaveChangesAsync();

            OrderContent.Id = OrderContentDAO.Id;
            return(true);
        }
Example #9
0
        private async Task SaveReference(Order Order)
        {
            await DataContext.OrderContent.Where(o => o.OrderId == Order.Id).DeleteFromQueryAsync();

            if (Order.OrderContents != null)
            {
                List <OrderContentDAO> OrderContentDAOs = new List <OrderContentDAO>();
                foreach (var OrderContent in Order.OrderContents)
                {
                    OrderContentDAO OrderContentDAO = new OrderContentDAO
                    {
                        Id   = OrderContent.Id,
                        Code = OrderContent.Code,
                        FoodFoodTypeMappingId = OrderContent.FoodFoodTypeMappingId,
                        OrderId  = OrderContent.OrderId,
                        Quantity = OrderContent.Quantity,
                        StatusId = OrderContent.StatusId
                    };
                    OrderContentDAOs.Add(OrderContentDAO);
                }
                DataContext.OrderContent.AddRange(OrderContentDAOs);
            }
            await DataContext.SaveChangesAsync();
        }
        public List <OrderFullInfo> GetClientOrdersFullInfoByState(int id_client, string state)
        {
            FastFoodEntities db = new FastFoodEntities();

            // khasni n nsift JWT o n checkeh

            List <TORDER> list = db.TORDERs.Where(o => o.id_client == id_client && o.order_state == state).OrderByDescending(o => o.order_datetime).ThenByDescending(o => o.id_order).ToList();

            List <OrderFullInfo> ordersFullInfo = list.Select(o => new OrderFullInfo()
            {
                id_order          = o.id_order,
                order_state       = o.order_state,
                latitude          = o.latitude,
                longitude         = o.longitude,
                order_datetime    = o.order_datetime,
                order_code        = o.order_code,
                delivery_state    = o.delivery_state,
                received_datetime = o.received_datetime,
                id_delivery_man   = o.id_delivery_man,
                id_client         = o.id_client,
                client            = new Client()
                {
                    id_client         = o.CLIENT.id_client,
                    firstname         = o.CLIENT.firstname,
                    lastname          = o.CLIENT.lastname,
                    gender            = o.CLIENT.gender,
                    email             = o.CLIENT.email,
                    password          = "",
                    phone             = o.CLIENT.phone,
                    photo             = o.CLIENT.photo,
                    confirmation_code = o.CLIENT.confirmation_code
                }
            }).ToList();


            ordersFullInfo.ForEach(o => {
                if (o.id_delivery_man == null)
                {
                    o.delivery_man = new Delivery_man();
                }
                else
                {
                    o.delivery_man = DeliveryManDAO.GetDeliveryMan((int)o.id_delivery_man);
                }

                List <Geolocation> geolocations = GeolocationDAO.GetOrderGeolocations(o.id_order);
                if (geolocations == null)
                {
                    o.geolocations = new List <Geolocation>();
                }
                else
                {
                    o.geolocations = geolocations;
                }

                List <Order_content> orderContents = OrderContentDAO.GetOrderContents(o.id_order);
                if (orderContents == null)
                {
                    o.order_contents = new List <Order_content>();
                }
                else
                {
                    o.order_contents = orderContents;
                }
            });


            return(ordersFullInfo);
        }
        public Order_content GetOrderContent(int id_order, int id_product)
        {
            // khasni n nsift JWT o n checkeh

            return(OrderContentDAO.GetOrderContent(id_order, id_product));
        }