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); }
public static List <PositionViewModel> GetAll() { PositionViewModel mappedPosition = new PositionViewModel(); List <PositionViewModel> list = new List <PositionViewModel>(); List <PositionDto> positions; HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Position").Result; positions = response.Content.ReadAsAsync <List <PositionDto> >().Result; foreach (var position in positions) { mappedPosition = Mapper.MapPosition(position); foreach (var staff in mappedPosition.Staff) { var staffinjected = StaffLoader.GetInsertedById(staff.Id); mappedPosition.Staff.Add(staffinjected); } list.Add(mappedPosition); } return(list); }
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); }
public static PositionViewModel GetById(int id) { PositionDto position; HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Position/" + id.ToString()).Result; position = response.Content.ReadAsAsync <PositionDto>().Result; var result = Mapper.MapPosition(position); result.Staff = StaffLoader.GetAll().Where(x => x.Position_id == result.Id).ToList(); return(result); }
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); }
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); }