Esempio n. 1
0
        public async Task <ActionResult> Login(string user)
        {
            user = Request.Form["login"];
            var Id = await _UserNameProvider.GetUserLoginByUserNameAsync(user);

            if (Id.UserName != null)
            {
                if (int.Parse(Id.Password) == int.Parse(Request.Form["password"]))
                {
                    var model = await _informationProvider.GetUser(user);

                    var ck = Request.Form["checkbox"];
                    if (ck == "on")
                    {
                        HttpCookie cookie = new HttpCookie("Login");
                        cookie["LoginUser"] = Id.UserName;
                        cookie["LoginPwd"]  = Id.Password;
                        cookie.Expires      = DateTime.Now.AddDays(7);
                        Response.Cookies.Add(cookie);
                    }
                    Session["LoginId"]       = user;
                    Session["Password"]      = Id.Password;
                    Session["LoginUserName"] = model.name;
                    Session["Power"]         = Id.Power;
                    if (Id.Power == "Manager")
                    {
                        return(RedirectToAction("Main", "InfoMedicine"));
                    }
                    else
                    {
                        return(RedirectToAction("UserMain", "InfoMedicine"));
                    }
                }
                else
                {
                    ViewBag.ErrorMessage = "Wrong Password";
                }
            }
            else
            {
                ViewBag.Error = "Wrong UserID";
            }
            return(View());
        }
Esempio n. 2
0
        public async Task <InformationViewModel> GetUser(int id)
        {
            var user = await _informationProvider.GetUser(Convert.ToString(id));

            return(user);
        }