public ActionResult <Product> Create(Product product) { //_context.Add(product); _context.Products.Add(product); _context.SaveChanges(); return(CreatedAtAction(nameof(GetById), new { id = product.ProductId }, product)); }
public IActionResult Create(Product product) { if (ModelState.IsValid) { _dbcontext.Products.Add(product); _dbcontext.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View()); }
public IActionResult Create(Customer customer) { if (ModelState.IsValid) { _context.Customers.Add(customer); _context.SaveChanges(); return(RedirectToAction("Index")); } else { return(View()); } }
public IActionResult Create(Customer customer) { if (ModelState.IsValid) { _dbcontext.Customers.Add(customer); _dbcontext.SaveChanges(); _customerCount.AddCustomerNumber(); return(RedirectToAction("Index")); } return(View()); }
public IActionResult Create(Product product) { if (ModelState.IsValid) { _context.Products.Add(product); _context.SaveChanges(); _productNumber.AddProductCount(); return(RedirectToAction(nameof(Index))); } else { return(View()); } }
public void Add <T>(ICollection <T> items) where T : class { using (FiscalContext context = new FiscalContext()) { context.Set <T>().AddRange(items); context.SaveChanges(); } }
public void Add <T>(T item) where T : class { using (FiscalContext context = new FiscalContext()) { context.Set <T>().Add(item); context.SaveChanges(); } }
public void Delete <T>(T item) where T : class { using (FiscalContext context = new FiscalContext()) { if (item is IIdentifier) { T element = context.Set <T>().Find(((IIdentifier)item).ID); context.Set <T>().Remove(element); context.SaveChanges(); } else { return; } } }