public ActionResult Category(int page = 1)
        {
            var model = new CategorySetupViewModel();

            model.CategorySetupViewModelList = _proCommon.GetAllCategories();
            ViewBag.currentPage = page;
            return(View(model));
        }
 public ActionResult InsertUpdateCategory(CategorySetupViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     if (_proCommon.InsertUpdateCategory(model))
     {
         return(RedirectToAction("Category"));
     }
     return(View(model));
 }
        public bool InsertUpdateCategory(CategorySetupViewModel model)
        {
            try
            {
                using (var con = new DirectoryEntities())
                {
                    if (model.DirectoryCategoryId > 0)
                    {
                        var record = con.tblDirectoryCategories.Where(x => x.DirectoryCategoryId == model.DirectoryCategoryId).FirstOrDefault();
                        if (record != null)
                        {
                            record.DirectoryCategoryId   = model.DirectoryCategoryId;
                            record.DirectoryCategoryName = model.DirectoryCategoryName;

                            con.Entry(record).State = System.Data.Entity.EntityState.Modified;
                        }
                    }
                    else
                    {
                        tblDirectoryCategory category = new tblDirectoryCategory()
                        {
                            DirectoryCategoryId   = model.DirectoryCategoryId,
                            DirectoryCategoryName = model.DirectoryCategoryName,
                        };
                        //category.CreatedBy = Utility.GetCurrentLoginUser();
                        category.CreatedDate = DateTime.Now.ToShortDateString().ToString();
                        con.tblDirectoryCategories.Add(category);
                    }
                    con.SaveChanges();

                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }