// // GET: /Manage/Index public ActionResult Index() { //ViewBag.StatusMessage = // message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." // : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set." // : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." // : message == ManageMessageId.Error ? "An error has occurred." // : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." // : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." // : ""; //var userId = User.Identity.GetUserId<int>(); //var model = new IndexViewModel //{ // HasPassword = HasPassword(), // PhoneNumber = await UserManager.GetPhoneNumberAsync(userId), // TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId), // Logins = await UserManager.GetLoginsAsync(userId), // BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId.ToString()) //}; //return View(model); ApplicationUser user = (ApplicationUser)Session["sesApplicationUser"]; ProfileViewModel profileViewModel = new ProfileViewModel(); PopulateProfileViewModel(profileViewModel); //profileViewModel.USERNAME = user.UserName; //profileViewModel.DATEOFBIRTH = user.DateOfBirth; //profileViewModel.COUNTRYNAME = _profileDAL.GetCountryByCountryId(user.CountryId).CountryName; //profileViewModel.STATENAME = _profileDAL.GetStateByStateId(user.StateId).StateName; //profileViewModel.TIMEZONENAME = _profileDAL.GetTimezoneByTimezoneId(user.TimeZoneId).TimeZoneName; //profileViewModel.TWITCHUSERID = user.TwitchId; //profileViewModel.PSNID = user.PSNId; //profileViewModel.XBOXID = user.XBoxId; return View("UserProfile", profileViewModel); }
private void PopulateProfileViewModel(ProfileViewModel objProfileViewModel) { ApplicationUser user = (ApplicationUser)Session["sesApplicationUser"]; _profileDAL = new ProfileDAL(); objProfileViewModel.USERNAME = user.UserName; objProfileViewModel.DATEOFBIRTH = user.DateOfBirth; if (user.CountryId > 0) { objProfileViewModel.COUNTRYNAME = _profileDAL.GetCountryByCountryId(user.CountryId).CountryName; } if (user.StateId > 0) { objProfileViewModel.STATENAME = _profileDAL.GetStateByStateId(user.StateId).StateName; } if (user.TimeZoneId > 0) { objProfileViewModel.TIMEZONENAME = _profileDAL.GetTimezoneByTimezoneId(user.TimeZoneId).TimeZoneName; } objProfileViewModel.TWITCHUSERID = user.TwitchId; objProfileViewModel.PSNID = user.PSNId; objProfileViewModel.XBOXID = user.XBoxId; objProfileViewModel.COUNTRYLIST = _profileDAL.GetAllCountries(); objProfileViewModel.STATELIST = _profileDAL.GetAllStates(); objProfileViewModel.TIMEZONELIST = _profileDAL.GetAllTimezones(); objProfileViewModel.SELECTEDCOUNTRYID = user.CountryId; objProfileViewModel.SELECTEDSTATEID = user.StateId; objProfileViewModel.SELECTEDTIMEZONEID = user.TimeZoneId; objProfileViewModel.profilePhoto = new ProfilePhotoModel(); objProfileViewModel.profilePhoto.PHOTOBINARY = user.ProfilePhoto; objProfileViewModel.AccountActivity = _profileDAL.GetAccountActivity(user.Id); }
public ActionResult Save(ProfileViewModel paramProfileViewModel) { if (ModelState.IsValid) { ApplicationUser objuser = (ApplicationUser)Session["sesApplicationUser"]; var user = UserManager.FindById(objuser.Id); user.UserName = paramProfileViewModel.USERNAME; user.CountryId = paramProfileViewModel.SELECTEDCOUNTRYID == null ? 0 : (int)paramProfileViewModel.SELECTEDCOUNTRYID; user.StateId = paramProfileViewModel.SELECTEDSTATEID == null ? 0 : (int)paramProfileViewModel.SELECTEDSTATEID; user.TimeZoneId = paramProfileViewModel.SELECTEDTIMEZONEID == null ? 0 : (int)paramProfileViewModel.SELECTEDTIMEZONEID; user.DateOfBirth = paramProfileViewModel.DATEOFBIRTH; user.TwitchId = paramProfileViewModel.TWITCHUSERID; user.PSNId = paramProfileViewModel.PSNID; user.XBoxId = paramProfileViewModel.XBOXID; Session["sesApplicationUser"] = user; UserManager.Update(user); Success("User Profile has been updated successfully",true); PopulateProfileViewModel(paramProfileViewModel); } else { ViewBag.Edit = true; _profileDAL = new ProfileDAL(); paramProfileViewModel.COUNTRYLIST = _profileDAL.GetAllCountries(); paramProfileViewModel.STATELIST = _profileDAL.GetAllStates(); paramProfileViewModel.TIMEZONELIST = _profileDAL.GetAllTimezones(); } return View("userProfile", paramProfileViewModel); }
public ActionResult Cancel() { ApplicationUser user = (ApplicationUser)Session["sesApplicationUser"]; ProfileViewModel profileViewModel = new ProfileViewModel(); ViewBag.Edit = false; PopulateProfileViewModel(profileViewModel); return View("UserProfile", profileViewModel); }
public ActionResult Edit() { ViewBag.Edit = true; ApplicationUser user = (ApplicationUser)Session["sesApplicationUser"]; ProfileViewModel profileViewModel = new ProfileViewModel(); PopulateProfileViewModel(profileViewModel); return View("UserProfile", profileViewModel); }
public async Task<JsonResult> CheckUsernameExistsProfile(ProfileViewModel profileViewModel) { ApplicationUser loggedInUser = (ApplicationUser)Session["sesApplicationUser"]; if (loggedInUser.UserName == profileViewModel.USERNAME) { return Json(new { exists = false }); } var user = await UserManager.FindByNameAsync(profileViewModel.USERNAME); if (user != null) { return Json(new { exists = true }); } else { return Json(new { exists = false }); } }