// GET: DropDownList
 public ActionResult Index()
 {
     using (BusinessLogicLayer.BLLContext ctx = new BusinessLogicLayer.BLLContext())
     {
         return(View(ctx.RelatedNumbers.GetAllRelatedNumbers()));
     }
 }
        public ActionResult Login(Models.LoginModel logininfo)
        {
            // logic to authenticate user goes here
            using (BusinessLogicLayer.BLLContext ctx = new BusinessLogicLayer.BLLContext())
            {
                var user = ctx.Users.FindUserByEmail(logininfo.Username);
                if (user == null)
                {
                    return(View(logininfo.SetMessage("not a Valid Username")));
                }

                string actual     = user.Password;
                string potential  = user.Salt + logininfo.Password;
                bool   checkedout = System.Web.Helpers.Crypto.
                                    VerifyHashedPassword(actual, potential);
                if (checkedout)
                {
                    Session["AUTHUsername"] = logininfo.Username;
                    Session["AUTHRoles"]    = user.Roles;
                    if (logininfo.ReturnURL == null)
                    {
                        logininfo.ReturnURL = @"~\home";
                    }
                    return(Redirect(logininfo.ReturnURL));
                }

                return(View(logininfo.SetMessage("Not a Valid Login")));
            }
        }
        public ActionResult Edit(int id)
        {
            using (BusinessLogicLayer.BLLContext ctx = new BusinessLogicLayer.BLLContext())
            {
                var relatednumber = ctx.RelatedNumbers.FindRelatedNumber(id);
                var numbers       = ctx.Numbers.GetAllNumbers();
                Models.DropDownViewForRelatedNumbers m = new Models.DropDownViewForRelatedNumbers();

                m.relatedNumber = relatednumber;
                m.SetValues(numbers);
                m.SelectedParentID = relatednumber.ParentNumberID;

                return(View(m));
            }
        }
示例#4
0
        public ActionResult Unauthorized(string EMail, string Password, string ReturnURL)
        {
            using (BusinessLogicLayer.BLLContext ctx = new BusinessLogicLayer.BLLContext())
            {
                var user = ctx.Users.FindUserByEmail(EMail);
                if (user == null)
                {
                    return(View((object)"Not a Valid EMail"));
                }
                string actual     = user.Password;
                string potential  = user.Salt + Password;
                bool   checkedout = System.Web.Helpers.Crypto.
                                    VerifyHashedPassword(actual, potential);
                if (checkedout)
                {
                    Session["AUTHUsername"] = EMail;
                    Session["AUTHRoles"]    = user.Roles;
                    return(Redirect(ReturnURL));
                }

                return(View(View((object)"Not a Valid Login")));
            }
        }