コード例 #1
0
        public async Task <IActionResult> Create([Bind("Id,ProductId,Quantity")] ItemDemand itemDemand)
        {
            if (ModelState.IsValid)
            {
                _context.Add(itemDemand);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(itemDemand));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,DemandDate,UserId,DeliveryDate,CEP,State,City,CompleteAddress,AddressNumber,PayWayId")] Demand demand)
        {
            if (ModelState.IsValid)
            {
                _context.Add(demand);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PayWayId"] = new SelectList(_context.PayWays, "Id", "Description", demand.PayWayId);
            ViewData["UserId"]   = new SelectList(_context.Users, "Id", "Email", demand.UserId);
            return(View(demand));
        }