Пример #1
0
        public ActionResult RoleApplication(int userIDField, string button)
        {
            Console.WriteLine("LoadRoleApplication triggered!");
            RoleApplicationModel applicant = new RoleApplicationModel();

            applicant.userID = userIDField;
            Console.WriteLine("ID: " + applicant.userID);
            Console.WriteLine("role: " + applicant.role);


            if (button == "refresh")
            {
                StringBuilder applicationListHtml = new StringBuilder("<table id=\"pplTbl\"><tr><th>User ID</th><th>First Name</th><th>Last Name</th><th>Role</th></tr>");
                applications = SqliteDataAccess.LoadRoleApplication();

                foreach (var app in applications)
                {
                    applicationListHtml.Append("<tr><td>");
                    applicationListHtml.Append(app.userID);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.fname);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.lname);
                    applicationListHtml.Append("</td><td>");
                    applicationListHtml.Append(app.role);
                    applicationListHtml.Append("</td></tr>");
                }

                applicationListHtml.Append("</table>");

                Console.WriteLine(applicationListHtml);

                TempData["RoleApps"] = applicationListHtml.ToString();
            }
            else if (button == "accept" && userIDField != 0)
            {
                //Finds the requested role
                applicant.role = SqliteDataAccess.SingleObjectString(applicant, "roleapplication", "userID", "role");
                //Approves request
                SqliteDataAccess.ApproveRole(applicant);
            }
            else if (button == "deny" && userIDField != 0)
            {
                SqliteDataAccess.DenyRole(applicant);
            }
            else
            {
                Console.WriteLine("Shit went wrong!");
            }
            return(RedirectToAction("Managment", "Home"));
        }