Example #1
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

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

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

            DeskQuote.QuotePrice = DeskQuote.getQuotePrice(_context);

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

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Desk.Add(Desk);

            await _context.SaveChangesAsync();

            DeskQuote.DeskId     = Desk.DeskId;
            DeskQuote.Desk       = Desk;
            DeskQuote.QuoteDate  = DateTime.Now;
            DeskQuote.QuotePrice = DeskQuote.getQuotePrice(_context);
            _context.DeskQuote.Add(DeskQuote);

            await _context.SaveChangesAsync();

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

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

            Desk = await _context.Desk.FindAsync(DeskQuote.DeskId);

            if (Desk != null)
            {
                _context.Desk.Remove(Desk);
            }

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

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