Beispiel #1
0
        public async Task <List <TimeTableRowViewModel> > GetTimeTable(int cookerID, DateTime fromDate)
        {
            var data = await _rc.GetDataAsync <List <TimeTableRowDTO> >(GetActionMethods.TimeTable, string.Format("{0}?fromDate={1}", cookerID, fromDate.ToString("yyyy-MM-dd")));

            List <TimeTableRowViewModel> list = new List <TimeTableRowViewModel>();

            foreach (var item in data)
            {
                var vm = new TimeTableRowViewModel()
                {
                    Day   = item.Day,
                    Hours = new List <TimeTableCellViewModel>()
                };
                foreach (var cell in item.Hours)
                {
                    vm.Hours.Add(new TimeTableCellViewModel()
                    {
                        IsTaken    = cell.IsTaken,
                        IsWorking  = cell.IsWorking,
                        Percentage = cell.Percentage
                    });
                }
                list.Add(vm);
            }

            return(list);
        }
Beispiel #2
0
        public async Task <CookerInformationViewModel> GetCookerInformation(int cookerID, DateTime fromDate)
        {
            CookerInformationViewModel cooker = new CookerInformationViewModel();

            CookerInformationDTO data = await _rc.GetDataAsync <CookerInformationDTO>(GetActionMethods.Cooker, string.Format("{0}?fromDate={1}", cookerID, fromDate.ToString("yyyy-MM-dd")));

            List <RecipeViewModel> recipes = new List <RecipeViewModel>();

            foreach (var item in data.Receipts)
            {
                recipes.Add(new RecipeViewModel()
                {
                    ID = item.ID, Image = item.Image, TimeToCook = item.TimeToCook, Title = item.Title, Portions = item.Portions
                });
            }

            var cuisines      = DataBase.Instance.Query <CuisineFilterDTO>();
            var cuisinesTypes = DataBase.Instance.Query <CuisineDTO>();

            ObservableCollection <CuisineTypeViewModel> list = new ObservableCollection <CuisineTypeViewModel>();

            foreach (var item in cuisines)
            {
                list.Add(new CuisineTypeViewModel()
                {
                    Code = item.Code, Description = item.Description, Cuisines = new List <CuisineViewModel>()
                });
            }

            foreach (var item in data.Cuisines)
            {
                var cuisineType = cuisinesTypes.Single(x => x.Code == item);
                list.Single(x => x.Code == cuisineType.CuisineTypeCode).Cuisines.Add(new CuisineViewModel {
                    Description = cuisineType.Description
                });
            }

            list = new ObservableCollection <CuisineTypeViewModel>(list.Where(x => x.Cuisines.Count > 0));

            List <TimeTableRowViewModel> timeTableRows = new List <TimeTableRowViewModel>();

            foreach (var item in data.Schedule)
            {
                var vm = new TimeTableRowViewModel()
                {
                    Day   = item.Day,
                    Hours = new List <TimeTableCellViewModel>()
                };
                foreach (var cell in item.Hours)
                {
                    vm.Hours.Add(new TimeTableCellViewModel()
                    {
                        IsTaken    = cell.IsTaken,
                        IsWorking  = cell.IsWorking,
                        Percentage = cell.Percentage
                    });
                }
                timeTableRows.Add(vm);
            }

            cooker.TimeTable      = timeTableRows;
            cooker.RecipesCanCook = recipes;
            cooker.CuisineTypes   = list;

            return(cooker);
        }