public ActionResult Index(HomeViewModel userLogin)
        {
            if (ModelState.IsValid)
            {
                Profile loginAccount = new Profile();
                loginAccount = profileTable.GetLoginAccount(userLogin.User, userLogin.Password);

                if ((loginAccount != null))
                {
                    Session.Add("user", loginAccount.UserName);
                    Session.Add("name", loginAccount.DisplayName);
                    Session.Add("id", loginAccount.ID);
                    Session.Add("sessionGUID", Guid.NewGuid());
                    Session.Add("profile", loginAccount);
                    Session.Add("avatarSrc", GetImageScrFromBytes(loginAccount.ProfileImage));
                    loginAccount.LastLogin       = DateTime.Now;
                    loginAccount.LastLoginDevice = Environment.MachineName.ToString();
                    loginAccount = profileTable.Update(loginAccount);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("Login Unsuccessful", "Incorrect Login");
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("Test", "Home"));
            }
        }
예제 #2
0
 public ActionResult Edit(ProfileViewModel profileViewModelToUpdate)
 {
     try
     {
         Profile profiletoUpdate = new Profile();
         profiletoUpdate.ID           = profileViewModelToUpdate.ProfileID;
         profiletoUpdate.DisplayName  = profileViewModelToUpdate.DisplayName;
         profiletoUpdate.IsTwoFactor  = profileViewModelToUpdate.IsTwoFactor;
         profiletoUpdate.IsSubscribed = profileViewModelToUpdate.IsSubscribed;
         profiletoUpdate     = inMemoryProfileTable.Update(profiletoUpdate);
         Response.StatusCode = SetStatus(string.Empty);
         return(RedirectToAction("Index", "Profile"));
     }
     catch (Exception ex)
     {
         Response.StatusCode = SetStatus(ex.Message);
         return(View());
     }
 }