예제 #1
0
 public ActionResult ProductCategoryDelete(ProductCategory_Model model)
 {
     try
     {
         if (productCategoryService.Delete(model.ProductCategoryID))
         {
             return(Json(model.ProductCategoryName + " has been deleted successfully"));
         }
         else
         {
             return(Json("Error"));
         }
     }
     catch (Exception e)
     {
         return(Json("Error" + e.ToString()));
     }
 }
 public bool Update(ProductCategory_Model model)
 {
     using (var _context = new SalesTrackingSystemEntities())
     {
         try
         {
             var data = _context.ProductCategories.Where(ProductCategory => ProductCategory.ProductCategoryID == model.ProductCategoryID).FirstOrDefault();
             data.ProductCategoryName = model.ProductCategoryName;
             data.IsSubCategory       = model.IsSubCategory;
             data.SubCategoryOf       = model.SubCategoryOf;
             data.CategoryStatus      = model.CategoryStatus;
             _context.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
예제 #3
0
 public ActionResult AddProductCategory(ProductCategory_Model productCategory_Model)
 {
     if (productCategory_Model.ProductCategoryName == null || productCategory_Model.CategoryStatus == null)
     {
         ViewBag.AddProductCategory = "Error";
         return(View("Products"));
     }
     else
     {
         if (productCategoryService.Save(productCategory_Model))
         {
             Session["Success"] = "Product Category inserted succcessfully";
             return(RedirectToAction("Products"));
         }
         else
         {
             Session["Error"] = "Error occured!!";
             return(View("Products"));
         }
     }
 }
예제 #4
0
 public ActionResult EditProductCategory(ProductCategory_Model productCategory)
 {
     if (string.IsNullOrWhiteSpace(productCategory.ProductCategoryName) || productCategory.CategoryStatus == null)
     {
         ViewBag.UpdateError          = "Error";
         ViewBag.UpdateProductCatData = productCategory.ProductCategoryID;
         return(View("Products"));
     }
     else
     {
         if (productCategoryService.Update(productCategory))
         {
             Session["Success"] = productCategory.ProductCategoryName + " updated successfully!!";
             return(RedirectToAction("Products"));
         }
         else
         {
             Session["Error"] = productCategory.ProductCategoryName + " couldn't be updated please retry!!";
             return(View("Products"));
         }
     }
 }
 public bool Save(ProductCategory_Model model)
 {
     using (var _context = new SalesTrackingSystemEntities())
     {
         try
         {
             var data = new ProductCategory()
             {
                 ProductCategoryName = model.ProductCategoryName,
                 IsSubCategory       = model.IsSubCategory,
                 SubCategoryOf       = model.SubCategoryOf,
                 CategoryStatus      = model.CategoryStatus,
                 DateCreated         = DateTime.Now
             };
             _context.ProductCategories.Add(data);
             _context.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             throw;
         }
     }
 }