Ejemplo n.º 1
0
        public IActionResult OnGet(int category, int dayId, bool isremoved = false)
        {
            IsRemoved = isremoved;
            Category  = category;
            DayId     = dayId;

            if (dayId != 0)
            {
                Day = dayData.GetById(dayId);
            }

            if (IsRemoved)
            {
                Meals = (from m in dayMealData.GetAll()
                         where m.DayId == Day.DayId && m.Category == (MealCategory)Category
                         select m.Meal)
                        .ToList();
            }
            else
            {
                Meals = mealData.GetMealsByOwner(User.Identity.Name);
            }

            return(Page());
        }
Ejemplo n.º 2
0
        public IActionResult GetById(int id)
        {
            try
            {
                Day = dayData.GetById(id);

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

                return(Ok(ApiRepository.DayToDto(Day)));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database Failure"));
            }
        }
Ejemplo n.º 3
0
        public IActionResult OnGet(int?dayId)
        {
            if (dayId.HasValue)
            {
                Day = dayData.GetById(dayId.Value);
            }
            else
            {
                Day = dayData.GetByDate(DateTime.Now.Date, User.Identity.Name);
            }

            if (Day == null)
            {
                InitializeDay();
            }

            if (Day.DayMeals.Count > 0)
            {
                PresentTodayMeals();
            }

            return(Page());
        }