public ActionResult SaveCategory(SA_Category UserCategory)
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);

                    var path = Path.Combine(Server.MapPath("~/ProductImages"), fileName);
                    file.SaveAs(path);
                    UserCategory.CategoryImg = fileName;
                }
            }
            UserCategory.CreatedTime = DateTime.Now;
            CategoryDataStore Obj = new CategoryDataStore();

            if (UserCategory.id == 0)
            {
                Obj.AddCategory(UserCategory);
            }
            else
            {
                Obj.EditCategory(UserCategory);
            }
            return(RedirectToAction("Category"));
        }
Beispiel #2
0
        public async Task <bool> UpdateCategory(SA_Category Category)
        {
            _context.Entry(Category).State = EntityState.Modified;
            //  Category.ModeifiedDate = DateTime.Now;
            int x = await _context.SaveChangesAsync();

            return(x == 0 ? false : true);
        }
Beispiel #3
0
        public async Task <bool> AddCategory(SA_Category Category)
        {
            //  Category.CreatedDate = DateTime.Now;
            _context.SA_Category.Add(Category);
            int x = await _context.SaveChangesAsync();

            return(x == 0 ? false : true);
        }
        public ActionResult AddCategory()
        {
            CategoryDataStore ObjDal          = new CategoryDataStore();
            SA_Category       objCatViewModel = new SA_Category();

            // objCatViewModel.ProductList = ObjDal.GetProductList();

            return(View("add-category", objCatViewModel));
        }
Beispiel #5
0
        public bool DeleteCategory(int CategoryId)
        {
            //  Category.CreatedDate = DateTime.Now;
            SA_Category EditCategory = _context.SA_Category.Where(Category => Category.id == CategoryId).FirstOrDefault();

            _context.Entry(EditCategory).State = EntityState.Deleted;
            int x = _context.SaveChanges();

            return(x == 0 ? false : true);
        }
        public ActionResult EditCategory(int id)
        {
            CategoryDataStore Obj = new CategoryDataStore();
            SA_Category       obj = Obj.GetCategoryByid(id);
            // List<SelectListItem> productList = Obj.GetProductList();
            SA_Category objSaCatV = new SA_Category();

            objSaCatV.id                  = obj.id;
            objSaCatV.CategoryName        = obj.CategoryName;
            objSaCatV.CategoryDiscription = obj.CategoryDiscription;
            objSaCatV.Meta                = obj.Meta;
            objSaCatV.MetaDiscription     = obj.MetaDiscription;
            objSaCatV.CategoryImg         = obj.CategoryImg;
            //   objSaCatV.ProductList = productList;



            return(View("add-Category", objSaCatV));
        }
Beispiel #7
0
        public bool EditCategory(SA_Category Category)
        {
            //  Category.CreatedDate = DateTime.Now;
            SA_Category EditCategory = _context.SA_Category.Where(Cat => Cat.id == Category.id).FirstOrDefault();

            EditCategory.CategoryName        = Category.CategoryName;
            EditCategory.CategoryDiscription = Category.CategoryDiscription;
            EditCategory.Meta            = Category.Meta;
            EditCategory.MetaDiscription = Category.MetaDiscription;
            //EditCategory.Product = Category.Product;
            if (Category.CategoryImg != null)
            {
                EditCategory.CategoryImg = Category.CategoryImg;
            }
            _context.Entry(EditCategory).State = EntityState.Modified;
            int x = _context.SaveChanges();

            return(x == 0 ? false : true);
        }