예제 #1
0
 public ActionResult Apply(AddStatementViewModel model)
 {
     if (User.Identity.IsAuthenticated && (User.IsInRole("Admin") || User.IsInRole("User")))
     {
         if (ModelState.IsValid)
         {
             if (model.Captcha != Session["code"].ToString())
             {
                 ModelState.AddModelError("Captcha", "Неправильно введений код перевірки!");
             }
             if (model.Consent == false)
             {
                 ModelState.AddModelError("Consent", "Потрібне підтвердження!");
             }
             if (ModelState.IsValid)
             {
                 StatementManager.ApplyStatement(model, User.Identity.GetUserId());
                 return(RedirectToAction("Index", "Home"));
             }
             List <Kindergarten> Kindergartens = KindergartenManager.GetKindergartens().ToList();
             model.Kindergartens = new SelectList(Kindergartens, "Id", "Name");
             return(View(model));
         }
     }
     return(RedirectToAction("Index", "Home"));
 }
예제 #2
0
        public ActionResult Apply(string id)
        {
            if (User.Identity.IsAuthenticated)
            {
                List <Privilege>      privileges    = StatementManager.GetAllPrivileges();
                List <Group>          groups        = StatementManager.GetAllGroups();
                List <Kindergarten>   Kindergartens = KindergartenManager.GetKindergartens().ToList();
                AddStatementViewModel model         = new AddStatementViewModel {
                };
                model.Privileges = new List <PrivilegesInnerViewModel> {
                };
                model.Groups     = new List <string> {
                };
                for (int i = 0; i < privileges.Count; i++)
                {
                    model.Privileges.Add(new PrivilegesInnerViewModel {
                        Key = privileges[i].Value, Value = false
                    });
                }
                for (int i = 0; i < groups.Count; i++)
                {
                    model.Groups.Add(groups[i].Value);
                }

                model.Kindergartens = new SelectList(Kindergartens, "Id", "Name");

                return(View(model));
            }
            return(RedirectToAction("Index", "Home"));
        }
 public ActionResult Kindergartens()
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
     {
         return(View(KindergartenManager.GetKindergartens()));
     }
     return(RedirectToAction("Index", "Home"));
 }