Exemplo n.º 1
0
        public ViewRestaurantSpecs(Restaurant restaurant)
        {
            this.InitializeComponent();
            Title = restaurant.Name;
            NavigationPage.SetBackButtonTitle(this, "");

            _restaurant = restaurant;

            Device.BeginInvokeOnMainThread(() =>
            {
            });

            Loading.IsVisible    = false;
            Loading.IsRunning    = false;
            SpecsPanel.IsVisible = true;

            lvFoodSpecials.ItemTapped += async(sender, e) =>
            {
                ((ListView)sender).SelectedItem = null;
                var flattenedSpec = (FoodSpecial)e.Item;
                var spec          = await FoodSpecialService.GetSpecsFromStorageAsync();

                await Navigation.PushAsync(new ManageFoodSpecial(spec.Single(x => x.SpecialId == flattenedSpec.SpecialId)));
            };
        }
Exemplo n.º 2
0
        async Task PopulateList(Restaurant restaurant)
        {
            var specs = await FoodSpecialService.GetSpecsFromStorageAsync();

            var foodSpecialsFlat = GetFlattenedFoodSpecials(specs.Where(x => x.RestaurantId == restaurant.Id));

            var groupings = foodSpecialsFlat
                            .GroupBy(fs => fs.DaysOfWeek.First())
                            .OrderBy(g => g.Key)
                            .Select(x => new Grouping <DayOfWeek, FoodSpecial>(x.Key, x));

            lvFoodSpecials.ItemsSource = new ObservableCollection <Grouping <DayOfWeek, FoodSpecial> >(groupings);

            lvFoodSpecials.IsGroupingEnabled = true;
        }
        /// <summary>
        /// Sets the values of the readonly fields
        /// </summary>
        async Task SetFields()
        {
            var spec = await FoodSpecialService.GetSpecsFromStorageAsync();

            _spec = spec.Single(x => x.SpecialId == _spec.SpecialId);
            RestaurantName.Text = _spec.Restaurant.Name;
            lblTitle.Text       = _spec.Title;
            if (_spec.Description != null)
            {
                lblDescription.Text = _spec.Description;
            }
            else
            {
                lblDescription.Text      = "(No description)";
                lblDescription.TextColor = Color.Gray;
            }

            lblDays.Text  = string.Join(", ", _spec.DaysOfWeek.Select(x => x.ToString()));            //Comma deliminate days of week
            lblHours.Text = _spec.Hours;
        }