예제 #1
0
        public static List <OrderViewModel> GetOrders()
        {
            OrderViewModel        mappedOrder = new OrderViewModel();
            List <OrderViewModel> list        = new List <OrderViewModel>();


            List <OrdersDto>    orders;
            HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Orders").Result;

            orders = response.Content.ReadAsAsync <IEnumerable <OrdersDto> >().Result.ToList();

            foreach (var order in orders)
            {
                mappedOrder        = Mapper.MapOrder(order);
                mappedOrder.Brunch = BrunchLoader.GetInsertedById(order.Brunch_id.GetValueOrDefault());
                mappedOrder.Staff  = StaffLoader.GetInsertedById(order.Staff_id.GetValueOrDefault());


                list.Add(mappedOrder);
            }



            return(list);
        }
예제 #2
0
        public static List <StaffViewModel> GetAll()
        {
            StaffViewModel        mappedStaff = new StaffViewModel();
            List <StaffViewModel> list        = new List <StaffViewModel>();


            List <StaffDto>     staffs;
            HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Staff").Result;

            staffs = response.Content.ReadAsAsync <List <StaffDto> >().Result;

            foreach (var staff in staffs)
            {
                mappedStaff          = Mapper.MapStaff(staff);
                mappedStaff.Brunch   = BrunchLoader.GetInsertedById(staff.Brunch_id);
                mappedStaff.Position = PositionLoader.GetInsertedById(staff.Position_id);
                foreach (var orders in staff.Orsers_id)
                {
                    var order = MVCDataLoader.OrderLoader.GetInsertedById(orders);
                    mappedStaff.Orders.Add(order);
                }


                list.Add(mappedStaff);
            }
            return(list);
        }
예제 #3
0
        public static OrderViewModel GetOrder(int id)
        {
            OrdersDto           order;
            HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Orders/" + id.ToString()).Result;

            order = response.Content.ReadAsAsync <OrdersDto>().Result;
            var result = Mapper.MapOrder(order);

            result.Staff  = StaffLoader.GetInsertedById(result.Staff_id.GetValueOrDefault());
            result.Brunch = BrunchLoader.GetInsertedById(result.Brunch_id.GetValueOrDefault());
            result.Gifts  = GiftsLoader.GetInsertedById(result.Gift_id.GetValueOrDefault());
            result.Client = ClientLoader.GetInsertedById(result.Client_id.GetValueOrDefault());

            return(result);
        }
예제 #4
0
        static public StaffViewModel  GetById(int id)
        {
            StaffDto            staff;
            HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Staff/" + id.ToString()).Result;

            staff = response.Content.ReadAsAsync <StaffDto>().Result;
            var result = Mapper.MapStaff(staff);

            result.Position = PositionLoader.GetInsertedById(result.Position_id);
            result.Brunch   = BrunchLoader.GetInsertedById(result.Brunch_id);
            foreach (var order in staff.Orsers_id)
            {
                var getorder = OrderLoader.GetOrder(order);

                result.Orders.Add(getorder);
            }
            return(result);
        }