示例#1
0
        public async Task <IActionResult> Create(Good good)
        {
            db.Goods.Add(good);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
示例#2
0
        public async Task <IActionResult> CreateGood(
            [FromBody] CreateGoodViewModel goodVm)
        {
            if (ModelState.IsValid)
            {
                _context.Goods.Add(new Good
                {
                    Name  = goodVm.Name,
                    Price = goodVm.Price
                });
                await _context.SaveChangesAsync();

                return(Ok());
            }
            return(BadRequest());
        }
示例#3
0
 public async Task AddAsync(User item)
 {
     db.Entry(item).State = EntityState.Added;
     await db.SaveChangesAsync();
 }