public async Task <IActionResult> Create([FromBody] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(Ok(customer));
        }
示例#2
0
        //  [HttpPost]
        public async Task <IActionResult> NewSales([FromBody] NewSalesRequest request)
        {
            var sale = new Sales
            {
                Datesold = DateTime.Now,
                Cust     = await _context.Customer.FindAsync(request.CustId),
                Prod     = await _context.Product.FindAsync(request.ProdId),
                Store    = await _context.Store.FindAsync(request.StoreId)
            };

            _context.Sales.Add(sale);
            await _context.SaveChangesAsync();

            return(Ok(sale));
        }