Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }