コード例 #1
0
        public ActionResult Index(int?Page, string SortBy = "Name", bool Ascending = true)
        {
            ViewBag.SuccessMsg = ViewBag.Failuremessage = "";
            CategorysModels      cvm           = new CategorysModels();
            List <CategoryList>  allCategories = _accountService.GetAllCategory();
            CategoryDisplayModel model         = new CategoryDisplayModel();

            model.Categorys   = allCategories;
            cvm.ListDataModel = model;
            return(View(cvm));
        }
コード例 #2
0
        public ActionResult Index(CategorysModels md)
        {
            if (ModelState.IsValid)
            {
                Api.MembershipCreateStatus createStatus;
                string currentUser = HttpContext.User.Identity.Name;

                int seltedID = md.SubmitFormModel.CategoryID;

                if (seltedID == 0)
                {
                    _accountService.CreateCategory(md.SubmitFormModel.CategoryName, md.SubmitFormModel.CategoryDescription, out createStatus);
                    if (createStatus == Api.MembershipCreateStatus.Success)
                    {
                        ModelState.Clear();
                        ViewBag.SuccessMsg = "Category created successfully";
                    }
                }
                else
                {
                    bool result = _accountService.UpdateCategory(md.SubmitFormModel.CategoryName, md.SubmitFormModel.CategoryDescription, md.SubmitFormModel.CategoryID);
                    if (result == true)
                    {
                        ModelState.Clear();
                        ViewBag.SuccessMsg = "Category updated successfully";
                    }
                    else
                    {
                        ViewBag.Failuremessage = "Unable to update please try again later!";
                    }
                }
            }
            CategorysModels      cvm           = new CategorysModels();
            List <CategoryList>  allCategories = _accountService.GetAllCategory();
            CategoryDisplayModel model         = new CategoryDisplayModel();

            model.Categorys   = allCategories;
            cvm.ListDataModel = model;
            return(View(cvm));
        }