getUser() public method

public getUser ( int UserID ) : userModel
UserID int
return userModel
Esempio n. 1
0
        public ActionResult Logon(String username, String password)
        {
            userModel user = new userModel();
            var authenticated = user.verify(username, password);
            var type = user.getUserType(authenticated);
            if (authenticated != 0)
            {
                user = user.getUser(authenticated);
                if (user.Expires_At != new DateTime())
                {
                    if (user.Expires_At.CompareTo(DateTime.Now) < 0)
                    {
                        ViewData["Message"] = "User account has expired";
                        return View();
                    }
                }
                Session["user_type"] = type;
                Session["sysadmin"] = "false";
                if (user.Reset_Password_Key != null && user.Reset_Password_Key.Equals("Created"))
                {
                    Session["Created"] = authenticated;
                    return RedirectToAction("ChangePassword", "User");
                }
                Session["uid"] = authenticated;

                return RedirectToAction("Index", "Home");
            }
            else
            {
                authenticated = user.verify_as_sys_admin(username, password);
                if (authenticated != 0)
                {
                    Session["uid"] = authenticated;
                    Session["user_type"] = type;
                    Session["sysadmin"] = "true";
                    return RedirectToAction("Index", "SysAdmin");
                }
                else
                {
                    ViewData["Message"] = "Username or password was incorrect";
                    return View();
                }
            }
        }
Esempio n. 2
0
        public ActionResult AssignPollCreator(int pollid, int[] selectedObjects, String pollname)
        {
            if (Session["uid"] == null || Session["uid"].ToString().Equals(""))
            {
                return RedirectToAction("Index", "Home");
            }
            if ((int)Session["user_type"] < User_Type.POLL_CREATOR)
            {
                return RedirectToAction("Invalid", "Home");
            }

            String errorString = "";

            new pollModel().assignPoll(pollid, selectedObjects);

            Assign_PollMasters pollMasters = new Assign_PollMasters();

            pollMasters.assigned = new userModel().displayAssignedUsers(pollid, User_Type.POLL_CREATOR);
            pollMasters.unassigned = new userModel().displayUnassignedUsers(pollid, User_Type.POLL_CREATOR);

                foreach (int id in selectedObjects)
                {
                    userModel u = new userModel();
                    u = u.getUser(id);
                    EmailController mail = new EmailController(pollname, u.username);

                    string mailSuccess = mail.send1();
                    if (!mailSuccess.Equals("Email sent successfully"))
                    {
                        errorString += u.username + "\n";
                        //throw new Exception(mailSuccess);
                    }
                }

            if(errorString.Length != 0)
                ViewData["emailError"] = "Could not send email to following Users: \n" + errorString;

            ViewData["pollid"] = pollid;
            ViewData["pollname"] = pollname;
            return View(pollMasters);
        }