public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyDeskQuote = new DeskQuote();


            if (await TryUpdateModelAsync <DeskQuote>(
                    emptyDeskQuote,
                    "deskQuote",
                    s => s.FirstName,
                    s => s.LastName,
                    s => s.QuoteDate,
                    s => s.RushDays,
                    s => s.Width,
                    s => s.Depth,
                    s => s.NumberOfDrawers,
                    s => s.DesktopMaterial))
            {
                _context.DeskQuote.Add(emptyDeskQuote);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Details", new { id = emptyDeskQuote.ID }));
            }

            return(null);
        }
示例#2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

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

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

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