public ActionResult Delete(int id, int tableSize, string sortColumn, bool asc, int currentPage)
        {
            var customer = _context.Customer.Find(id);

            if (customer == null)
            {
                return(NotFound());
            }

            _context.Customer.Remove(customer);
            _context.SaveChanges();
            return(Ok(new Message(true, "Success", GetCustomers(tableSize, sortColumn, asc, currentPage))));
        }
        public ActionResult Delete(int id, int tableSize, string sortColumn, bool asc, int currentPage)
        {
            var product = _context.Product.Find(id);

            if (product == null)
            {
                return(NotFound());
            }

            _context.Product.Remove(product);
            _context.SaveChanges();
            return(Ok(new Message(true, "Success", GetProducts(tableSize, sortColumn, asc, currentPage))));
        }
 public ActionResult SaveNewProduct(Products product)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Products.Add(product);
             db.SaveChanges();
             return(RedirectToAction(nameof(Index)));
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(RedirectToAction(nameof(Index)));
     }
 }
 public ActionResult SaveNewSale(Sales sale)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Sales.Add(sale);
             db.SaveChanges();
             return(RedirectToAction(nameof(Index)));
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(RedirectToAction(nameof(Index)));
     }
 }
Example #5
0
 public ActionResult SaveNewCustomer(Customers customer)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Customers.Add(customer);
             db.SaveChanges();
             return(RedirectToAction(nameof(Index)));
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(RedirectToAction(nameof(Index)));
     }
 }