コード例 #1
0
        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
        public async Task <IActionResult> Create([FromBody] Sales Sale)
        {
            if (ModelState.IsValid)
            {
                Sale.Datesold = DateTime.Now;
                _context.Add(Sale);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(Ok(Sale));
        }