Example #1
0
        //
        // GET: /Category/

        public ActionResult Index()
        {
            @ViewBag.CurrentPageLocation = "Category";
            try
            {
                drCategory = new DR_Category();
                int iTotalRows = 0;
                lstCategories        = drCategory.getCategoryList(ref iTotalRows);
                ViewBag.TotalRecords = iTotalRows;
            }
            catch (Exception ex)
            {
            }
            return(View(lstCategories));
        }
Example #2
0
        public ActionResult Create(Category category, HttpPostedFileBase file, FormCollection postedForm)
        {
            try
            {
                //getting file name if uploaded
                if (file != null)
                {
                    FileInfo fi = new FileInfo(file.FileName);
                    category.HomeImage = category.Title + fi.Extension;
                }

                //getting checkbox values
                if (postedForm["chkHomeAccess"] != null)
                {
                    category.HomeImageAccess = Convert.ToString(postedForm["chkHomeAccess"]) == "on" ? true : false;
                }

                if (postedForm["chkBannerAccess"] != null)
                {
                    category.HomePageAccess = Convert.ToString(postedForm["chkBannerAccess"]) == "on" ? true : false;
                }

                //insert into database
                drCategory = new DR_Category();
                bool result = drCategory.CreateCategory(category);

                //upload file
                if (result && file != null)
                {
                    file.SaveAs(Server.MapPath(CategoryPath) + category.HomeImage);
                }
            }
            catch (Exception ex)
            {
            }

            return(RedirectToAction("Index", "Category"));
        }