Beispiel #1
0
 public ActionResult <Product> Create(Product product)
 {
     //_context.Add(product);
     _context.Products.Add(product);
     _context.SaveChanges();
     return(CreatedAtAction(nameof(GetById), new { id = product.ProductId }, product));
 }
Beispiel #2
0
        public IActionResult Create(Product product)
        {
            if (ModelState.IsValid)
            {
                _dbcontext.Products.Add(product);
                _dbcontext.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }

            return(View());
        }
Beispiel #3
0
 public IActionResult Create(Customer customer)
 {
     if (ModelState.IsValid)
     {
         _context.Customers.Add(customer);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
Beispiel #4
0
        public IActionResult Create(Customer customer)
        {
            if (ModelState.IsValid)
            {
                _dbcontext.Customers.Add(customer);
                _dbcontext.SaveChanges();
                _customerCount.AddCustomerNumber();

                return(RedirectToAction("Index"));
            }

            return(View());
        }
Beispiel #5
0
 public IActionResult Create(Product product)
 {
     if (ModelState.IsValid)
     {
         _context.Products.Add(product);
         _context.SaveChanges();
         _productNumber.AddProductCount();
         return(RedirectToAction(nameof(Index)));
     }
     else
     {
         return(View());
     }
 }
Beispiel #6
0
 public void Add <T>(ICollection <T> items) where T : class
 {
     using (FiscalContext context = new FiscalContext())
     {
         context.Set <T>().AddRange(items);
         context.SaveChanges();
     }
 }
Beispiel #7
0
 public void Add <T>(T item) where T : class
 {
     using (FiscalContext context = new FiscalContext())
     {
         context.Set <T>().Add(item);
         context.SaveChanges();
     }
 }
Beispiel #8
0
 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;
         }
     }
 }