예제 #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();
 }