Пример #1
0
        public ActionResult Database(string ID)
        {
            try
            {
                // Get database details.
                DatabaseInfo database = MgmtMdl.GetDatabase(ID);

                // Verify user privileges.
                if (database.Owner != User.Identity.GetADUsername())
                {
                    System.Web.HttpContext.Current.Session["StatusMessage"] = "You do not have permisson to access the <strong>" + database.Name + "</strong> database.";
                    return(RedirectToAction("Index", "View"));
                }

                return(View("Database", database));
            }
            catch (Exception e)
            {
                System.Web.HttpContext.Current.Session["ErrorInfo"] = e.ToString();
                return(RedirectToAction("Error", "View"));
            }
        }
Пример #2
0
        public virtual ActionResult ChangeUsername(string ID)
        {
            try
            {
                // Preset form.
                ChangeUsernameSubmission changeUsernameSubmission = new ChangeUsernameSubmission();

                // Fetch database info.
                DatabaseInfo database = MgmtMdl.GetDatabase(ID);
                changeUsernameSubmission.Database = database;

                // Verify user privileges.
                if (database.Owner != User.Identity.GetADUsername())
                {
                    System.Web.HttpContext.Current.Session["StatusMessage"] = "You do not have permisson to access the <strong>" + database.Name + "</strong> database.";
                    return(RedirectToAction("Index", "View"));
                }

                // Verify database information.
                if (database.Password == "")
                {
                    System.Web.HttpContext.Current.Session["StatusMessage"] = "Username cannot be changed. Password is missing.";
                    return(RedirectToAction("Database", "View", new { id = database.DatabaseID }));
                }


                return(View("ChangeUsername", changeUsernameSubmission));
            }
            catch (Exception e)
            {
                System.Web.HttpContext.Current.Session["ErrorInfo"] = e.ToString();
                return(RedirectToAction("Error", "View"));
            }
        }