コード例 #1
0
        public ActionResult DeleteThatCategory(string categoryName)
        {
            PolicyGrinder grinder = PolicyGrinderFactory.Synthesize();

            grinder.DeleteCategory(categoryName);
            return(RedirectToAction("ViewCategories"));
        }
コード例 #2
0
        public ActionResult DeletePolicy(Policy policy)
        {
            PolicyGrinder grinder = PolicyGrinderFactory.Synthesize();

            grinder.DeletePolicy(policy);
            return(RedirectToAction("ManagePolicies"));
        }
コード例 #3
0
        public ActionResult DeleteCategory(string categoryName)
        {
            PolicyGrinder    grinder  = PolicyGrinderFactory.Synthesize();
            CategoryResponse category = grinder.GetOneCategory(categoryName);

            return(View(category));
        }
コード例 #4
0
        public ActionResult ManagePolicies()
        {
            PolicyGrinder grinder   = PolicyGrinderFactory.Synthesize();
            var           viewModel = new CategoryVM();

            viewModel.CategoryList = grinder.GetAllCategoryies();
            return(View(viewModel));
        }
コード例 #5
0
        public void CanSearchOnePolicy(string name, bool expectedResults)
        {
            PolicyGrinder grinder = PolicyGrinderFactory.Synthesize();
            Policy        policy  = new Policy();

            policy.Name = name;
            PolicyResponse response = grinder.GetOnePolicy(policy);

            Assert.AreEqual(expectedResults, response.Success);
        }
コード例 #6
0
        public void CanDeleteCategory(string name, bool expectedResults)
        {
            PolicyGrinder grinder  = PolicyGrinderFactory.Synthesize();
            Category      category = new Category();

            category.Name = name;
            CategoryResponse response = grinder.DeleteCategory(category.Name);

            Assert.AreEqual(expectedResults, response.Success);
        }
コード例 #7
0
        public ActionResult ManagePolicies(int categoryId)
        {
            PolicyGrinder grinder      = PolicyGrinderFactory.Synthesize();
            var           viewModel    = new CategoryVM();
            var           categoryList = grinder.GetAllCategoryies();

            viewModel.CategoryList = categoryList;
            viewModel.Category     = categoryList.FirstOrDefault(c => c.Id == categoryId);
            return(View(viewModel));
        }
コード例 #8
0
 public ActionResult AddCategory(Category category)
 {
     if (ModelState.IsValid)
     {
         PolicyGrinder    grinder  = PolicyGrinderFactory.Synthesize();
         CategoryResponse response = grinder.AddNewCategory(category);
         return(RedirectToAction("ManagePolicies", response));
     }
     return(View(new Category()));
 }
コード例 #9
0
 public ActionResult AddPolicy(Policy policy)
 {
     if (ModelState.IsValid)
     {
         PolicyGrinder  grinder  = PolicyGrinderFactory.Synthesize();
         PolicyResponse response = grinder.AddNewPolicy(policy);
         return(RedirectToAction("ManagePolicies", response));
     }
     return(View(policy));
 }
コード例 #10
0
 public ActionResult ApplicationHome(Applicant applicant)
 {
     if (ModelState.IsValid)
     {
         PolicyGrinder grinder = PolicyGrinderFactory.Synthesize();
         grinder.AddApplicant(applicant);
         return(RedirectToAction("ConfirmApplication"));
     }
     return(View());
 }
コード例 #11
0
        public void CanDeletePolicy(string name, string content, bool expectedResults)
        {
            PolicyGrinder grinder = PolicyGrinderFactory.Synthesize();
            Policy        policy  = new Policy();

            policy.Name    = name;
            policy.Content = content;
            PolicyResponse response = grinder.DeletePolicy(policy);

            Assert.AreEqual(expectedResults, response.Success);
        }
コード例 #12
0
        public ActionResult Policy(string id, string reference)
        {
            PolicyGrinder grinder   = PolicyGrinderFactory.Synthesize();
            Policy        newPolicy = new Policy();

            if (reference != null && reference == "categories")
            {
                ViewBag.LinkText       = "Return to View Policies";
                ViewBag.LinkAction     = "Categories";
                ViewBag.LinkController = "Admin";
            }
            else
            {
                ViewBag.LinkText       = "Return to Manage Policies";
                ViewBag.LinkAction     = "ManagePolicies";
                ViewBag.LinkController = "Admin";
            }
            newPolicy.Name = id;
            var policySearched = grinder.GetOnePolicy(newPolicy);

            return(View(policySearched));
        }