Esempio n. 1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var Tuote = await _context.Tuote

                        .AsNoTracking()
                        .FirstOrDefaultAsync(m => m.ID == id);

            if (Tuote == null)
            {
                return(NotFound());
            }
            try
            {
                _context.Tuote.Remove(Tuote);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            catch (DbUpdateException)
            {
                return(RedirectToAction("./Delete",
                                        new { id, saveChangesError = true }));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Tuote).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TuoteExists(Tuote.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Tuote.Add(Tuote);
            await _context.SaveChangesAsync();

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