Exemple #1
0
        public ActionResult Category(CategoryModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                Api.MembershipCreateStatus createStatus;
                string currentUser = HttpContext.User.Identity.Name;
                _accountService.CreateCategory(model.CategoryName, model.CategoryDescription, out createStatus);

                if (createStatus == Api.MembershipCreateStatus.Success)
                {
                    ViewBag.SuccessMsg = 1;
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }
            return(View(model));
        }
Exemple #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));
        }