public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Meal meal = await _context.Meals.GetAsync((int)id);

            if (meal != null)
            {
                //send selected meal and active event list to edit view
                MealsEventModel mealsEventModel = new MealsEventModel
                {
                    EventList = new SimpleEventModel {
                        EventId = (int)ViewBag.EventId, EventName = (string)ViewBag.EventName
                    }
                    , CurrentMeal = new MealsIndexViewModel
                    {
                        Id = meal.Id
                        , BreakfastPrice = meal.BreakfastPrice
                        , DinnerPrice    = meal.DinnerPrice
                        , EventId        = meal.EventId
                        , EventName      = (string)ViewBag.EventName
                        , LunchPrice     = meal.LunchPrice
                        , VenueName      = meal.VenueName
                    }
                };
                return(View(mealsEventModel));
            }
            else
            {
                return(RedirectToAction(nameof(Index)));
            }
        }
        public async Task <IActionResult> Index()
        {
            //get current user
            AppUser appUser = await _userManager.GetUserAsync(HttpContext.User);

            //get the biggest role for this user
            RoleDependency biggestRoleforCurrentUser = await _roleManager.GetBiggestRoleAsync(_userManager, appUser, _context.RoleDependencies);

            //assign it to dynamic View for comparing
            ViewBag.BiggestRoleForCurrentUser = biggestRoleforCurrentUser;
            IEnumerable <MealsIndexViewModel> mealsData = new List <MealsIndexViewModel>();

            if ((await _context.Meals.CountAsyncByEvent((int)ViewBag.EventId)) != 0)
            {
                mealsData = (await _context.Meals
                             .GetAllByEventIdAsync((int)ViewBag.EventId))
                            .Select(x =>
                                    new MealsIndexViewModel
                {
                    Id = x.Id
                    ,
                    BreakfastPrice = x.BreakfastPrice
                    ,
                    DinnerPrice = x.DinnerPrice
                    ,
                    EventId = x.EventId
                    ,
                    EventName = ((Event)ViewBag.CurrentEvent).Name
                    ,
                    LunchPrice = x.LunchPrice
                    ,
                    VenueName = x.VenueName,
                    CreatedBy = x.AppUserId
                });
            }


            MealsEventModel mealsEventModel = new MealsEventModel
            {
                MealsIndexViewModel = mealsData
                , EventList         = new SimpleEventModel {
                    EventId = (int)ViewBag.EventId, EventName = (string)ViewBag.EventName
                }
            };

            return(View(mealsEventModel));
        }