Пример #1
0
        public static List <BrunchViewModel> GetBrunches()
        {
            BrunchViewModel        mappedBrunch = new BrunchViewModel();
            List <BrunchViewModel> list         = new List <BrunchViewModel>();


            IEnumerable <BrunchDto> brunchList;
            HttpResponseMessage     response = GlobalVariables.WebApiClient.GetAsync("Brunch").Result;

            brunchList = response.Content.ReadAsAsync <IEnumerable <BrunchDto> >().Result;

            foreach (var brunch in brunchList)
            {
                mappedBrunch = Mapper.MapBrunch(brunch);

                foreach (var item in brunch.OrdersId)
                {
                    OrderViewModel order = OrderLoader.GetOrder(item);
                    mappedBrunch.Orders.Add(order);
                }
                foreach (var item in brunch.StaffId)
                {
                    StaffViewModel staff = new StaffViewModel();
                    staff = StaffLoader.GetInsertedById(item);
                    mappedBrunch.Staff.Add(staff);
                }

                list.Add(mappedBrunch);
            }

            return(list);
        }
Пример #2
0
        public static List <GiftsViewModel> GetGifts()
        {
            GiftsViewModel        mappedGift = new GiftsViewModel();
            List <GiftsViewModel> list       = new List <GiftsViewModel>();


            List <GiftsDto>     gifts;
            HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Gift").Result;

            gifts = response.Content.ReadAsAsync <List <GiftsDto> >().Result;

            foreach (var gift in gifts)
            {
                mappedGift = Mapper.MapGift(gift);
                foreach (var item in gift.OrdersId)
                {
                    mappedGift.Orders.Add(OrderLoader.GetOrder(item));
                }


                list.Add(mappedGift);
            }



            return(list);
        }
Пример #3
0
        public static GiftsViewModel GetGift(int id)
        {
            GiftsDto            gift;
            HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Gift/" + id.ToString()).Result;

            gift = response.Content.ReadAsAsync <GiftsDto>().Result;
            var result = Mapper.MapGift(gift);

            foreach (var item in gift.OrdersId)
            {
                result.Orders.Add(OrderLoader.GetInsertedById(item));
            }



            return(result);
        }
Пример #4
0
        public static ClientViewModel GetById(int id)
        {
            ClientDto           client;
            HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Clients/" + id.ToString()).Result;

            client = response.Content.ReadAsAsync <ClientDto>().Result;

            var result = Mapper.MapClient(client);

            foreach (var ordertid in client.OrdersId)
            {
                result.Orders.Add(OrderLoader.GetOrder(ordertid));
            }



            return(result);
        }
Пример #5
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);
        }
Пример #6
0
        public static BrunchViewModel GetBrunch(int id)
        {
            BrunchDto           brunch;
            HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Brunch/" + id.ToString()).Result;

            brunch = response.Content.ReadAsAsync <BrunchDto>().Result;
            var result = Mapper.MapBrunch(brunch);

            foreach (var item in brunch.OrdersId)
            {
                result.Orders.Add(OrderLoader.GetOrder(item));
            }

            foreach (var item in brunch.StaffId)
            {
                result.Staff.Add(StaffLoader.GetInsertedById(item));
            }



            return(result);
        }