Пример #1
0
        public List <Order_content> GetOrderContentsByIdOrder(int id_order)
        {
            // khasni n nsift JWT o n checkeh


            return(OrderContentDAO.GetOrderContents(id_order));
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }