// GET: Profile public async Task<ActionResult> Index(ManageController.ManageMessageId? message) { ViewBag.StatusMessage = message == ManageController.ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." : message == ManageController.ManageMessageId.SetPasswordSuccess ? "Your password has been set." : message == ManageController.ManageMessageId.SetTwoFactorSuccess ? "Your two factor provider has been set." : message == ManageController.ManageMessageId.Error ? "An error has occurred." : message == ManageController.ManageMessageId.AddPhoneSuccess ? "The phone number was added." : message == ManageController.ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." : ""; var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())); var currentUser = await manager.FindByIdAsync(User.Identity.GetUserId()); var model = new IndexViewModel { HasPassword = HasPassword(), PhoneNumber = await UserManager.GetPhoneNumberAsync(User.Identity.GetUserId()), TwoFactor = await UserManager.GetTwoFactorEnabledAsync(User.Identity.GetUserId()), Logins = await UserManager.GetLoginsAsync(User.Identity.GetUserId()), BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(User.Identity.GetUserId()), FirstName = currentUser.UserProfile.FirstName, LastName = currentUser.UserProfile.LastName, Email = currentUser.UserProfile.Email, Address1 = currentUser.UserProfile.Address1, City = currentUser.UserProfile.City, ProvState = currentUser.UserProfile.ProvState, PostZipCode = currentUser.UserProfile.PostZipCode, Country = currentUser.UserProfile.Country, Telephone = currentUser.UserProfile.Telephone, AvatarImgUrl = currentUser.UserProfile.AvatarImgUrl, }; ViewBag.UserId = User.Identity.GetUserId(); return View(model); }
//Receive Ajax call //public ActionResult GetMerchantDetails(string id) //{ // //Get current user // //var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())); // var profileId = UserManager.FindById(id).UserProfile.Id; // //var currentUser = UserManager.FindById(User.Identity.GetUserId()); // var merchant = _merchantServie.FindSupplierBy(profileId); // return PartialView("_MerchantDetails", merchant); //} //public ActionResult GetMerchantEdit(string id) //{ // var profileId = UserManager.FindById(id).UserProfile.Id; // //var currentUser = UserManager.FindById(User.Identity.GetUserId()); // var merchant = _merchantServie.FindSupplierBy(profileId); // return PartialView("_MerchantEdit", merchant); //} //Ajax call to get full name public async Task<ActionResult> GetFullName() { var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())); var currentUser = await manager.FindByIdAsync(User.Identity.GetUserId()); var model = new IndexViewModel { //HasPassword = HasPassword(), //PhoneNumber = await UserManager.GetPhoneNumberAsync(User.Identity.GetUserId()), //TwoFactor = await UserManager.GetTwoFactorEnabledAsync(User.Identity.GetUserId()), //Logins = await UserManager.GetLoginsAsync(User.Identity.GetUserId()), //BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(User.Identity.GetUserId()), FirstName = currentUser.UserProfile.FirstName, LastName = currentUser.UserProfile.LastName, //Email = currentUser.UserProfile.Email, //Address1 = currentUser.UserProfile.Address1, //City = currentUser.UserProfile.City, //ProvState = currentUser.UserProfile.ProvState, //PostZipCode = currentUser.UserProfile.PostZipCode, //Country = currentUser.UserProfile.Country, //Telephone = currentUser.UserProfile.Telephone, //AvatarImgUrl = currentUser.UserProfile.AvatarImgUrl, }; return PartialView("_Name", model); }