Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Description,Price")] LunchPack lunchPack)
        {
            if (id != lunchPack.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lunchPack);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LunchPackExists(lunchPack.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(lunchPack));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,Description,Price")] LunchPack lunchPack)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lunchPack);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(lunchPack));
        }
Beispiel #3
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            LunchPack = await _context.LunchPack.FirstOrDefaultAsync(m => m.Id == id);

            if (LunchPack == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            LunchPack = await _context.LunchPack.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }