public ActionResult Index(string username) { var user = DataContext.Users.Include(x => x.FRUser).Include(x => x.Previews.Select(p => p.Skin)).FirstOrDefault(x => x.UserName.ToLower() == username.ToLower()); if (user == null) { AddErrorNotification($"No user with username '{username}' could be found"); return(RedirectToRoute("Home")); } else if (!user.ProfileSettings.PublicProfile) { AddErrorNotification("This user's profile is set to private"); return(RedirectToRoute("Home")); } var vm = new ViewProfileViewModel { User = user }; if (user.ProfileSettings.ShowPreviewsOnProfile) { vm.Previews = user.Previews.ToList(); } if (user.ProfileSettings.ShowSkinsOnProfile) { vm.Skins = user.Skins.Where(x => x.Visibility == SkinVisiblity.Visible || x.Visibility == SkinVisiblity.HideFromBrowse).ToList(); } if (LoggedInUser != null && user.ProfileSettings.ShowPingListsOnProfile) { vm.Pinglists = user.Pinglists.Where(x => x.IsPublic || x.Entries.Any(e => e.FRUser.User?.Id == LoggedInUser.Id)).ToList(); } return(View(vm)); }
public async Task<IActionResult> Index(string Email) { var user = await userManager.FindByEmailAsync(Email); if (user == null) { ViewBag.ErrorMessage = $"User with Id = {Email} cannot be found"; return View("NotFound"); } var model = new ViewProfileViewModel { Id = user.Id, Email = user.Email, UserName = user.UserName, FirstName = user.FirstName, LastName = user.LastName, Gender = user.Gender, DOB = user.DOB, Country = user.Country, PhotoPath=user.PhotoPath }; return View(model); }
public ActionResult Index(RequestProfileViewModel view) { string csvProfilesPath = Server.MapPath(@"bin\MortalityProfiles.csv"); MortalityReporter reporter = new MortalityReporter(new TimeProvider(), csvProfilesPath); LifeReport report = reporter.GetLifeReport(view.Birthday.Value, view.Gender.Value, view.SelectedCountry); ViewProfileViewModel responseView = new ViewProfileViewModel(view); responseView.Countries = CountryCatalog.GetCountryList(); responseView.Messsage = MortalityReporter.FormatMessage(report); responseView.LifeExpectancyGraph = CreateExpectancyGraph(report.WeeksLived, report.ExpectedWeeks); return(this.View("Report", responseView)); }
public ActionResult viewProfile() { if ((Session["userId"] == null) || (Convert.ToInt32(Session["type"]) != 2)) { return(RedirectToAction("login", "Common")); } ViewProfileViewModel VPVM = new ViewProfileViewModel(); VPVM.repairman = _RepairmanService.GetById(Convert.ToInt32(Session["userId"])); return(View(VPVM)); }
private async Task <ActionResult> RedirectToProfile(User user) { User loggedInUser = await _userManager.GetUserAsync(HttpContext.User); ViewProfileViewModel viewProfileView = new ViewProfileViewModel { User = user, IsLoggedInUser = (user.Id.Equals(loggedInUser.Id)), LoggedInUserSubscribed = IsSubscribedTo(loggedInUser.Id, user.Id) != null }; return(View("ViewProfile", viewProfileView)); }
public ActionResult Index() { var vm = new ViewProfileViewModel { User = LoggedInUser, Previews = LoggedInUser.Previews.ToList(), Skins = LoggedInUser.Skins.ToList(), Pinglists = LoggedInUser.Pinglists.ToList(), IsOwn = true, }; AddInfoNotification($"You are looking at your own profile, you will see everything regardless of settings. To see your profile as others see it visit <a href=\"{Url.RouteUrl("Profile", new { username = vm.User.UserName })}\"><b>this link</b></a>. To edit your profile, go to the edit page <a href=\"{Url.RouteUrl("EditProfile")}\"><b>here</b></a>."); return(View(vm)); }
public async Task <IActionResult> EditProfile() { ApplicationUser user = await _userManager.GetUserAsync(User); var viewProfileViewModel = new ViewProfileViewModel { Name = user.Name, Language = user.Language, ImageUri = user.ImageUri, DefaultImageUri = _cdnService.GetDefaultProfileImageUri(), BaseUrl = _configuration["Urls:PersonalAssistant"] }; return(View(viewProfileViewModel)); }
public ActionResult RenderMemberProfile(string profileURLtoCheck) { //Try and find member with the QueryString value ?profileURLtoCheck=warrenbuckley Member findMember = Member.GetAllAsList().FirstOrDefault(x => x.getProperty("profileURL").Value.ToString() == profileURLtoCheck); //Create a view model ViewProfileViewModel profile = new ViewProfileViewModel(); //Check if we found member if (findMember != null) { //Increment profile view counter by one int noOfProfileViews = 0; int.TryParse(findMember.getProperty("numberOfProfileViews").Value.ToString(), out noOfProfileViews); //Increment counter by one findMember.getProperty("numberOfProfileViews").Value = noOfProfileViews + 1; //Save it down to the member findMember.Save(); //Got the member lets bind the data to the view model profile.Name = findMember.Text; profile.MemberID = findMember.Id; profile.EmailAddress = findMember.Email; profile.MemberType = findMember.Groups.Values.Cast <MemberGroup>().First().Text; profile.Description = findMember.getProperty("description").Value.ToString(); profile.LinkedIn = findMember.getProperty("linkedIn").Value.ToString(); profile.Skype = findMember.getProperty("skype").Value.ToString(); profile.Twitter = findMember.getProperty("twitter").Value.ToString(); profile.NumberOfLogins = Convert.ToInt32(findMember.getProperty("numberOfLogins").Value.ToString()); profile.LastLoginDate = DateTime.ParseExact(findMember.getProperty("lastLoggedIn").Value.ToString(), "dd/MM/yyyy @ HH:mm:ss", null); profile.NumberOfProfileViews = Convert.ToInt32(findMember.getProperty("numberOfProfileViews").Value.ToString()); } else { //Couldn't find the member return a 404 return(new HttpNotFoundResult("The member profile does not exist")); } return(PartialView("ViewProfile", profile)); }
public ActionResult RenderMemberProfile(string profileURLtoCheck) { //Try and find member with the QueryString value ?profileURLtoCheck=warrenbuckley var findMember = Services.MemberService.GetMembersByPropertyValue("profileURL", profileURLtoCheck).FirstOrDefault(); //Check if we found member if (findMember != null) { //Create a view model ViewProfileViewModel profile = new ViewProfileViewModel(); //Increment profile view counter by one int noOfProfileViews = findMember.GetValue <int>("numberOfProfileViews"); findMember.SetValue("numberOfProfileViews", noOfProfileViews + 1); //Save it down to the member Services.MemberService.Save(findMember); //Got the member lets bind the data to the view model profile.Name = findMember.Name; profile.MemberID = findMember.Id; profile.EmailAddress = findMember.Email; profile.MemberType = string.Join(",", System.Web.Security.Roles.GetRolesForUser(findMember.Username)); profile.Description = findMember.GetValue <string>("description"); profile.LinkedIn = findMember.GetValue <string>("linkedIn"); profile.Skype = findMember.GetValue <string>("skype"); profile.Twitter = findMember.GetValue <string>("twitter"); profile.NumberOfLogins = findMember.GetValue <int>("numberOfLogins"); profile.LastLoginDate = DateTime.ParseExact(findMember.GetValue <string>("lastLoggedIn"), "dd/MM/yyyy @ HH:mm:ss", null); profile.NumberOfProfileViews = findMember.GetValue <int>("numberOfProfileViews"); return(PartialView("ViewProfile", profile)); } else { //Couldn't find the member return a 404 return(new HttpNotFoundResult("The member profile does not exist")); } }
public ActionResult ViewProfile(int id = 0) { var user = ApplicationUserEngine.GetApplicationUser(id); if (user != null) { var profile = new ViewProfileViewModel { DisplayName = $"{user.DisplayName}#{user.Id}", AboutMe = user.AboutMe, CreateDate = user.CreateDate }; return(View(profile)); } TempData["AlertMsg"] = "<br /><div class=\"alert alert-danger alert-dismissible\">" + "<a href=\"#\" class=\"close\" data-dismiss=\"alert\" aria-label=\"close\">×</a>" + "<strong>This user does not exist or has a private profile.</div>"; return(View("Error")); }
public override ActionResult Index(RenderModel model) { //Get profileURLtoCheck string profileURLtoCheck = Request.RequestContext.RouteData.Values["profileURLtoCheck"].ToString(); //Create a view model ViewProfileViewModel profile = new ViewProfileViewModel(); var membershipService = ApplicationContext.Services.MemberService; //Check we have a value in the URL if (!String.IsNullOrEmpty(profileURLtoCheck)) { //var currentMember = memmembershipService..GetById(this.base.Umbraco.UmbracoHelper.Members.GetCurrentMemberId())); //Try and find member with the QueryString value ?profileURLtoCheck=warrenbuckley //Member findMember = Member.GetAllAsList().FirstOrDefault(x => x.getProperty("profileURL").Value.ToString() == profileURLtoCheckMember); var findMember = membershipService.GetMembersByPropertyValue("profileURL", profileURLtoCheck, StringPropertyMatchType.Exact).SingleOrDefault(); //Check if we found member if (findMember != null) { //Increment profile view counter by one int noOfProfileViews = 0; int.TryParse(findMember.Properties["numberOfProfileViews"].Value.ToString(), out noOfProfileViews); //Increment counter by one findMember.Properties["numberOfProfileViews"].Value = noOfProfileViews + 1; //Save it down to the member membershipService.Save(findMember); int noOfLogins = 0; int.TryParse(findMember.Properties["numberOfLogins"].Value.ToString(), out noOfLogins); //Got the member lets bind the data to the view model profile.Name = findMember.Name; profile.MemberID = findMember.Id; profile.EmailAddress = findMember.Email; //profile.Description = findMember.Properties["description"].Value.ToString(); //profile.LinkedIn = findMember.Properties["linkedIn"].Value.ToString(); //profile.Skype = findMember.Properties["skype"].Value.ToString(); //profile.Twitter = findMember.Properties["twitter"].Value.ToString(); profile.NumberOfLogins = noOfLogins; profile.LastLoginDate = findMember.LastLoginDate; profile.NumberOfProfileViews = noOfProfileViews; } else { //Couldn't find the member return a 404 return(new HttpNotFoundResult("The member profile does not exist")); } } else { //Couldn't find the member return a 404 return(new HttpNotFoundResult("No profile URL parameter was provided")); } //Return template with our profile model return(CurrentTemplate(profile)); }
private void OnLoad(object sender, RoutedEventArgs e) { this.ViewProfileViewModel = new ViewProfileViewModel(); this.DataContext = ViewProfileViewModel; }
public override ActionResult Index(RenderModel model) { //Get profileURLtoCheck string profileURLtoCheck = Request.RequestContext.RouteData.Values["profileURLtoCheck"].ToString(); //Create a view model ViewProfileViewModel profile = new ViewProfileViewModel(); //Check we have a value in the URL if (!String.IsNullOrEmpty(profileURLtoCheck)) { //Try and find member with the QueryString value ?profileURLtoCheck=warrenbuckley Member findMember = Member.GetAllAsList().FirstOrDefault(x => x.getProperty("profileURL").Value.ToString() == profileURLtoCheck); //Check if we found member if (findMember != null) { //Increment profile view counter by one int noOfProfileViews = 0; int.TryParse(findMember.getProperty("numberOfProfileViews").Value.ToString(), out noOfProfileViews); //Increment counter by one findMember.getProperty("numberOfProfileViews").Value = noOfProfileViews + 1; //Save it down to the member findMember.Save(); int noOfLogins = 0; int.TryParse(findMember.getProperty("numberOfLogins").Value.ToString(), out noOfLogins); //Got the member lets bind the data to the view model profile.Name = findMember.Text; profile.MemberID = findMember.Id; profile.EmailAddress = findMember.Email; profile.Description = findMember.getProperty("description").Value.ToString(); profile.LinkedIn = findMember.getProperty("linkedIn").Value.ToString(); profile.Skype = findMember.getProperty("skype").Value.ToString(); profile.Twitter = findMember.getProperty("twitter").Value.ToString(); profile.NumberOfLogins = noOfLogins; profile.LastLoginDate = DateTime.ParseExact(findMember.getProperty("lastLoggedIn").Value.ToString(), "dd/MM/yyyy @ HH:mm:ss", CultureInfo.InvariantCulture); profile.NumberOfProfileViews = noOfProfileViews; } else { //Couldn't find the member return a 404 return(new HttpNotFoundResult(DictionaryHelper.GetDictItem("MemberProfileDoesNotExist", "The member profile does not exist"))); } } else { //Couldn't find the member return a 404 return(new HttpNotFoundResult(DictionaryHelper.GetDictItem("NoProfileURLParameter", "No profile URL parameter was provided"))); } //Return template with our profile model return(CurrentTemplate(profile)); }
public async Task <IActionResult> Index(string user) { if (user == null) { return(this.LocalRedirect("/")); } ApplicationUser userData = this.context.Users.FirstOrDefault(x => x.UserName == user); if (userData == null) { return(this.LocalRedirect("/")); } await this.context.Entry(userData) .Collection(x => x.Followers) .LoadAsync(); await this.context.Entry(userData) .Collection(x => x.Following) .LoadAsync(); await this.context.Entry(userData) .Collection(x => x.Posts) .LoadAsync(); ViewProfileViewModel model = new ViewProfileViewModel { Username = userData.UserName, FollowersCount = userData.Followers.Count, FollowingCount = userData.Following.Count }; if (this.GetCurrentUserAsync().Result.UserName == userData.UserName) { model.Posts = userData.Posts.ToList(); } else { foreach (FollowerRelation relation in userData.Followers) { await this.context.Entry(relation) .Reference(x => x.Follower) .LoadAsync(); await this.context.Entry(relation) .Reference(x => x.Following) .LoadAsync(); } model.IsFollowing = userData.Followers.Any(x => x.Following.UserName == this.GetCurrentUserAsync().Result.UserName); if (model.IsFollowing) { model.Posts = userData.Posts.ToList(); } else { model.Posts = userData.Posts.ToList().Where(x => x.Privacy == PostPrivacyOptions.Public).ToList(); } } foreach (Post post in model.Posts) { await this.context.Entry(post) .Reference(x => x.OriginalPost) .LoadAsync(); await this.context.Entry(post) .Collection(x => x.Comments) .LoadAsync(); foreach (Comment comment in post.Comments) { await this.context.Entry(comment) .Reference(x => x.Author) .LoadAsync(); } Post originalPost = post.OriginalPost; while (originalPost != null) { await this.context.Entry(originalPost) .Reference(x => x.OriginalPost) .LoadAsync(); await this.context.Entry(originalPost) .Reference(x => x.Author) .LoadAsync(); originalPost = originalPost.OriginalPost; } } model.Posts = model.Posts.OrderByDescending(x => x.PostedOn).ToList(); return(this.View(model)); }
private void ViewProfile(IProfileSettings profileSettings) { var vm = new ViewProfileViewModel(profileSettings); var dlg = Repository.Instance.ViewManager.ShowModal(vm); }