public async Task <IActionResult> ManageEdit(int?id)
        {
            int eventId = ViewBag.EventId;

            if (id == null)
            {
                return(NotFound());
            }

            MealsReservation mealsReservation = (await _context.MealsReservation.GetWithRelatedDataByIdAsync((int)id));

            if (mealsReservation != null)
            {
                MealsReservationEditModel mealsReservationEditModel = new MealsReservationEditModel
                {
                    MealsReservation = mealsReservation,
                    Venues           = (await _context.Meals.GetWithRelatedDataByEventIdAsync(eventId))
                                       .Select(x => new VenueModel {
                        VenueId = x.Id, VenueName = x.VenueName
                    })
                };

                return(View(mealsReservationEditModel));
            }
            else
            {
                return(RedirectToAction(nameof(ManageMeals)));
            }
        }
        public async Task <IActionResult> ManageEdit(int?id, int MealTypeId, [Bind("Id,MealId,CheckInDate,MealType,PricePerPerson,Quantity,SubTotal")] MealsReservation mealsReservation)
        {
            if (id == null || mealsReservation?.Id != id || (MealTypeId < 0 || MealTypeId > 3))
            {
                return(NotFound());
            }

            int eventId = ViewBag.EventId;

            mealsReservation.MealType = (MealType)MealTypeId;

            MealsReservation currentMealsReservation = await _context.MealsReservation.GetAsync((int)id);

            if (ModelState.IsValid && currentMealsReservation != null)
            {
                var  loggableMeals = currentMealsReservation.Clone();
                Meal currentMeal   = (await _context.Meals.GetAllByEventIdAsync((int)eventId)).Where(x => x.Id == mealsReservation.MealId).SingleOrDefault();

                float?price = mealsReservation.MealType == MealType.Breakfast
                                          ? currentMeal.BreakfastPrice : mealsReservation.MealType == MealType.Lunch
                                           ? currentMeal.LunchPrice : currentMeal.DinnerPrice;
                if (price == null)
                {
                    ModelState.AddModelError("err", "Price is not correct!!");
                }
                else
                {
                    currentMealsReservation.PricePerPerson = (decimal)(float)price;
                    currentMealsReservation.SubTotal       = mealsReservation.Quantity * Convert.ToDecimal(price);
                    currentMealsReservation.Quantity       = mealsReservation.Quantity;
                    currentMealsReservation.UpdatedAt      = DateTime.Now;
                    //  currentMealsReservation.AppUserId = ViewBag.UserId;
                    currentMealsReservation.MealId   = mealsReservation.MealId;
                    currentMealsReservation.MealType = mealsReservation.MealType;
                    _context.Update <MealsReservation>(currentMealsReservation);

                    //try to log
                    await this.LogForUpdateAsync <MealsReservation>(_context.LiveLogs, loggableMeals, currentMealsReservation, "Accommodation-Meals(Administration)");

                    //commit
                    await _context.SaveAsync();
                }
            }
            else
            {
                return(View(mealsReservation));
            }
            return(RedirectToAction(nameof(ManageMeals)));
        }