public async Task <IActionResult> Create(Good good) { db.Goods.Add(good); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
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()); }
public async Task AddAsync(User item) { db.Entry(item).State = EntityState.Added; await db.SaveChangesAsync(); }