public ActionResult UserProfile(UserProfileViewModels userProfile) { if (this.User.Identity.IsAuthenticated) { if (userProfile.Profile != null) { string userId = this.User.Identity.GetUserId(); if (db.Profile.Where(x => x.Id_User == userId).Count() > 0) { userProfile.Profile.Id_User = userId; db.Profile.Attach(userProfile.Profile); db.Entry(userProfile.Profile).State = EntityState.Modified; db.SaveChanges(); } else { userProfile.Profile.Id_User = userId; db.Profile.Add(userProfile.Profile); db.SaveChanges(); } } } ViewBag.Gender = new SelectList(db.Gender, "Id", "Name"); ViewBag.Messenger = new SelectList(db.Messenger, "Id", "Name"); ViewBag.CivilStatus = new SelectList(db.CivilStatus, "Id", "Name"); ViewBag.Sector = new SelectList(db.Sector, "Id", "Name"); return(View("Index")); }
// // GET: /Manage/Index public async Task <ActionResult> Index(ManageMessageId?message) { 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(); ViewBag.Gender = new SelectList(db.Gender, "Id", "Name"); ViewBag.Messenger = new SelectList(db.Messenger, "Id", "Name"); ViewBag.CivilStatus = new SelectList(db.CivilStatus, "Id", "Name"); ViewBag.Sector = new SelectList(db.Sector, "Id", "Name"); 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) }; UserProfileViewModels viewModel = new UserProfileViewModels(); viewModel.IndexViewModel = model; viewModel.Profile = db.Profile.Where(p => p.Id_User == userId).SingleOrDefault(); return(View(viewModel)); }
public ActionResult UserProfile(string userId) { var user = _userRepository.GetById(userId); if (user == null) { return(View("Error")); } var userChalange = _chalangeRepository.GetChalangeByUserId(user.Id); var userProfile = new UserProfileViewModels() { Username = user.UserName, Points = user.Points, Interests = user.Interests }; userProfile.Chalanges = userChalange; return(View("UserProfile", userProfile)); }
// GET: Profile public ActionResult UserProfile() { var LoggedInUser = db.tblUserLoginInfoes.Where(x => x.UserName == System.Web.HttpContext.Current.User.Identity.Name).FirstOrDefault(); var WorkForceUser = db.tblWorkForces.Where(x => x.Id == LoggedInUser.WorkforceId)?.FirstOrDefault(); var Designation = WorkForceUser != null?db.tblDesignations.Where(x => x.Id == WorkForceUser.DesignationId)?.FirstOrDefault() : null; var UserProfile = new UserProfileViewModels { PersonName = WorkForceUser?.PersonName, ContactEmail = WorkForceUser?.ContactEmail, ContactNumber = WorkForceUser?.ContactNumber, Designation = Designation?.Designation, FacilityName = LoggedInUser.tblFacility?.FacilityName, IsEmployee = (WorkForceUser?.IsEmployee == true) ? "Employee" : "Vendor", UserName = LoggedInUser?.UserName, Password = LoggedInUser?.Password }; return(View(UserProfile)); }
// GET: UserProfile public ActionResult Index(int?id) { // --- Insert Database Pull for matching user ID here --- UserProfileViewModels model = new UserProfileViewModels(); ContactProfile dbContactProfileModel = db.ContactProfiles.FirstOrDefault(i => i.ProfileId == id); try { // Copy over Data model.About = dbContactProfileModel.About; model.Address = dbContactProfileModel.StreetAddress; model.AlternateEmail = dbContactProfileModel.AlternateEmail; model.AlternatePhone = dbContactProfileModel.AlternatePhone; model.AvailableForWorkMessage = ""; // dbContactProfileModel.AvailableForWorkMessage; model.City = dbContactProfileModel.City; model.Country = dbContactProfileModel.Country; model.CurrentlyWorkingOnMessage = dbContactProfileModel.CurrentWork; model.GitHubProfile = dbContactProfileModel.GitHub; model.HireByMessage = dbContactProfileModel.HiredBy; model.LinkInProfile = dbContactProfileModel.LinkedIn; model.PersonalWebsite = dbContactProfileModel.PersonalWebsite; model.PrimaryEmail = dbContactProfileModel.PrimaryEmail; model.PrimaryPhone = dbContactProfileModel.PrimaryPhone; model.ProfilePhoto = dbContactProfileModel.Photo; model.ShowAddress = dbContactProfileModel.ShowAddress; model.ShowAlternateEmail = dbContactProfileModel.ShowAlternateEmail; model.ShowAlternatePhone = dbContactProfileModel.ShowAlternatePhone; model.ShowAvailableForWorkMessage = dbContactProfileModel.ShowAvailableForWork; model.ShowCurrentlyWorkingOnMessage = dbContactProfileModel.ShowCurrentlyWorking; model.ShowGitHubProfile = dbContactProfileModel.ShowGitHubLink; model.ShowHireByMessage = dbContactProfileModel.ShowHireByMessage; model.ShowLinkInProfile = dbContactProfileModel.ShowLinkedInLink; model.ShowPersonalWebsite = dbContactProfileModel.ShowPersonalWebsiteLink; model.ShowPrimaryEmail = dbContactProfileModel.ShowPrimaryEmail; model.ShowPrimaryPhone = dbContactProfileModel.ShowPrimaryPhone; model.ShowProfilePhoto = dbContactProfileModel.ShowProfilePhoto; model.ShowResume = true; // dbContactProfileModel.ShowResume; model.State = dbContactProfileModel.USAState; model.UserFirstName = dbContactProfileModel.FirstName; model.UserLastName = dbContactProfileModel.LastName; model.Zip = dbContactProfileModel.PostalCode; // Generate Project List List <ProjectSpotlight> dbProjectList = db.ProjectSpotlights.Where(p => p.ProfileID == id).ToList(); model.ProjectSpotLightObjectList = new List <ProjectSpotlight>(); foreach (ProjectSpotlight projectItem in dbProjectList) { model.ProjectSpotLightObjectList.Add(projectItem); } // Pull resume from database model.ResumeHtmlUpload = db.UserResumes.FirstOrDefault(i => i.ProfileID == id); return(View(model)); } catch (Exception e) { return(RedirectToAction("Index", "Home")); } }