Example #1
0
        public async Task <IActionResult> OnGetAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Recipes = await _context.DayRecipes.FirstOrDefaultAsync(m => m.RecipeId == id);

            if (Recipes == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #2
0
        public async Task <IActionResult> OnPostAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Recipes = await _context.DayRecipes.FindAsync(id);

            if (Recipes != null)
            {
                _context.DayRecipes.Remove(Recipes);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Example #3
0
        public async Task <IActionResult> OnGetAsync(Guid?id = null, long tics = -1)
        {
            if (tics == -1)
            {
                tics = DateTime.UtcNow.Date.Ticks;
            }
            if (id == null)
            {
                Recipe            = new DayRecipes();
                RecipeFoods       = new List <DayRecipeFood>();
                Recipe.RecipeDate = new DateTime(tics);
            }
            else
            {
                Recipe = await _context.DayRecipes
                         .Include(r => r.DayRecipeFood).FirstOrDefaultAsync(m => m.RecipeId == id && m.RecipeDate == new DateTime(tics));

                RecipeFoods = await _context.DayRecipeFood.Where(rf => rf.RecipeId == Recipe.RecipeId)
                              .Include(f => f.Food).ToListAsync();
            }
            return(Page());
        }