public IActionResult Add(DataViewModel.CategoryViewModel categories)
 {
     try
     {
         if (categories.cat_id > 0)
         {
             Category cat = _context.categories.Find(categories.cat_id);
             cat.category = categories.category;
             _context.Update(cat);
             _context.SaveChanges();
             return(Json(new { success = true }));
         }
         else
         {
             Category cat = new Category();
             cat.category = categories.category;
             _context.Add(cat);
             _context.SaveChanges();
             return(Json(new { success = true, cid = cat.cat_id }));
         }
         //  return Json(new { success = false });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public IActionResult Editsupplier(Supplier sup)
 {
     if (ModelState.IsValid)
     {
         var uploads = Path.Combine(_environment.WebRootPath, "images");
         if (sup.file != null && sup.file.Length > 0)
         {
             var fileName = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(sup.file.FileName);
             using (var fileStream = new FileStream(Path.Combine(uploads, fileName), FileMode.Create))
             {
                 sup.file.CopyTo(fileStream);
                 sup.image = fileName;
             }
         }
         _context.Update(sup);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sup));
 }