Пример #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            List <SurfaceMaterial> rawSurfaceMaterials = await _context.SurfaceMaterials.ToListAsync();

            DeskQuote.Desk.SurfaceMaterial = rawSurfaceMaterials.FirstOr(m => m.Name == SelectedMaterial, rawSurfaceMaterials[0]);
            DeskQuote.QuotePrice           = DeskQuote.GetQuote(await _context.RushOrderTypes.ToListAsync());
            DeskQuote.Date = DateTime.Now;

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

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

            return(RedirectToPage("./Index"));
        }
Пример #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            List <SurfaceMaterial> rawSurfaceMaterials = await _context.SurfaceMaterials.ToListAsync();

            DeskQuote.Desk.SurfaceMaterial = rawSurfaceMaterials.FirstOr(m => m.Name == SelectedMaterial, rawSurfaceMaterials[0]);
            DeskQuote.QuotePrice           = DeskQuote.GetQuote(await _context.RushOrderTypes.ToListAsync());
            DeskQuote.Date = DateTime.Now;
            _context.Desks.Add(DeskQuote.Desk);
            _context.DeskQuotes.Add(DeskQuote);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Пример #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DeskQuote = await _context.DeskQuotes.Include(dq => dq.Desk)
                        .Include(dq => dq.Desk.SurfaceMaterial).FirstOrDefaultAsync(m => m.DeskQuoteId == id);

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

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