コード例 #1
0
        public async Task LoadDataAsync(string enterprise_id = null)
        {
            IsEnabled = false;
            IsEnabled = IsEnabled;
            _catList  = await catService.GetAllCategoriesAsync();

            CategoryNames = _catList.Select((c) => c.Name).ToList();
            if (enterprise_id != null)
            {
                _isEditScreen = true;
                try
                {
                    var items = await entService.GetEnterpriseAsync(enterprise_id);

                    Enterprise = items.First();
                    if (Enterprise.Tags != null)
                    {
                        if (Enterprise.Tags.Count > 0)
                        {
                            TagList = string.Join(",", Enterprise.Tags.Select(t => t.Name));
                        }
                    }
                    if (Enterprise.Categories != null)
                    {
                        if (Enterprise.Categories.Count > 0)
                        {
                            SelectedCatName = Enterprise.Categories[0].Name;
                        }
                    }
                    if (Enterprise.Opening_Hours != null)
                    {
                        if (Enterprise.Opening_Hours.Count > 0)
                        {
                            if (Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 0).FirstOrDefault() != null)
                            {
                                Monday = Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 0).First();
                            }
                            if (Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 1).FirstOrDefault() != null)
                            {
                                Tuesday = Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 1).First();
                            }
                            if (Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 2).FirstOrDefault() != null)
                            {
                                Wednesday = Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 2).First();
                            }
                            if (Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 3).FirstOrDefault() != null)
                            {
                                Thursday = Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 3).First();
                            }
                            if (Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 4).FirstOrDefault() != null)
                            {
                                Friday = Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 4).First();
                            }
                            if (Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 5).FirstOrDefault() != null)
                            {
                                Saturday = Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 5).First();
                            }
                            if (Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 6).FirstOrDefault() != null)
                            {
                                Sunday = Enterprise.Opening_Hours.Where(o => o.Day_Of_Week == 6).First();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    toastService.ShowToast("Er ging iets mis", "probeer later opnieuw");
                    IsEnabled = true;
                    IsEnabled = IsEnabled;
                }
            }

            OpeningHours.Add(Monday);
            OpeningHours.Add(Tuesday);
            OpeningHours.Add(Wednesday);
            OpeningHours.Add(Thursday);
            OpeningHours.Add(Friday);
            OpeningHours.Add(Saturday);
            OpeningHours.Add(Sunday);

            IsEnabled = true;
            IsEnabled = IsEnabled;
        }