/// <summary> /// Prepare the profile index model /// </summary> /// <param name="customer">Customer</param> /// <param name="page">Number of posts page; pass null to disable paging</param> /// <returns>Profile index model</returns> public virtual ProfileIndexModel PrepareProfileIndexModel(Customer customer, int?page) { if (customer == null) { throw new ArgumentNullException(nameof(customer)); } var pagingPosts = false; var postsPage = 0; if (page.HasValue) { postsPage = page.Value; pagingPosts = true; } var name = _customerService.FormatUserName(customer); var title = string.Format(_localizationService.GetResource("Profile.ProfileOf"), name); var model = new ProfileIndexModel { ProfileTitle = title, PostsPage = postsPage, PagingPosts = pagingPosts, CustomerProfileId = customer.Id, ForumsEnabled = _forumSettings.ForumsEnabled }; return(model); }
public ActionResult Index(int?id, int?page) { if (!_customerSettings.AllowViewingProfiles) { return(RedirectToRoute("HomePage")); } var customerId = 0; if (id.HasValue) { customerId = id.Value; } var customer = _customerService.GetCustomerById(customerId); if (customer == null || customer.IsGuest()) { return(RedirectToRoute("HomePage")); } bool pagingPosts = false; int postsPage = 0; if (page.HasValue) { postsPage = page.Value; pagingPosts = true; } var name = customer.FormatUserName(); var title = string.Format(_localizationService.GetResource("Profile.ProfileOf"), name); var model = new ProfileIndexModel { ProfileTitle = title, PostsPage = postsPage, PagingPosts = pagingPosts, CustomerProfileId = customer.Id, ForumsEnabled = _forumSettings.ForumsEnabled }; //display "edit" (manage) link if (_permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel) && _permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) { DisplayEditLink(Url.Action("Edit", "Customer", new { id = customer.Id, area = "Admin" })); } return(View(model)); }
public IActionResult Index(string id) { if (string.IsNullOrEmpty(id)) { id = HttpContext.User.Identity.Name; } var indexModel = new ProfileIndexModel(_accountClient); indexModel.User = _accountClient.GetUserByUserId(id); indexModel.Posts = _postService.GetUserPostsByUserId(id); indexModel.SetRelationship(HttpContext.User.Identity.Name); return(View(indexModel)); }
public ActionResult Index(int?id, int?page) { if (!_customerSettings.AllowViewingProfiles) { return(RedirectToRoute("HomePage")); } var customerId = 0; if (id.HasValue) { customerId = id.Value; } var customer = _customerService.GetCustomerById(customerId); if (customer == null || customer.IsGuest()) { return(RedirectToRoute("HomePage")); } bool pagingPosts = false; int postsPage = 0; if (page.HasValue) { postsPage = page.Value; pagingPosts = true; } var name = customer.FormatUserName(); var title = string.Format(_localizationService.GetResource("Profile.ProfileOf"), name); var model = new ProfileIndexModel { ProfileTitle = title, PostsPage = postsPage, PagingPosts = pagingPosts, CustomerProfileId = customer.Id, ForumsEnabled = _forumSettings.ForumsEnabled }; return(View(model)); }
public IActionResult Index() { ViewData["ServerName"] = Program.ServerName; ViewData["Title"] = "角色列表"; var user = ByteConverter.ToObject <Users>(HttpContext.Session.Get("User")); var profiles = from p in db.Profiles where p.Uid == user.Id select p; var profilesList = new List <Profiles>(); foreach (var item in profiles) { profilesList.Add(item); } var model = new ProfileIndexModel() { Profiles = profilesList }; return(View(model)); }
public ActionResult Index(long?distNumber = null, int page = 1, int pageSize = 10, GridSortOptions sort = null) { var model = new ProfileIndexModel(); if (distNumber.HasValue) { // Set distributor data var distributor = _distributorService.GetDistributorById(distNumber.Value); if (distributor != null) { model.Distributor = distributor.ToModel <ProfileIndexModel.DistributorModel>(); } // Set profile box data if (sort == null || string.IsNullOrEmpty(sort.Column)) { sort = new GridSortOptions() { Column = "CreatedDate", Direction = SortDirection.Descending } } ; ViewBag.Sort = sort; var boxes = _profileService.SearchProfilesByDistNumber( distNumber.Value, page, pageSize, sort.Column, WebUtility.GetSortDir(sort)); model.ProfileBoxes = boxes.Select(x => x.ToModel <ProfileIndexModel.ProfileModel>()).ToList(); model.Pager = boxes.ToMvcPaging(model.ProfileBoxes); // If current page > total pages, redirect to last page if (model.Pager.TotalPages > 0 && model.Pager.PageNumber > model.Pager.TotalPages) { return(Redirect(Url.Paging(model.Pager.TotalPages, model.Pager.PageSize).ToString())); } } return(View(model)); }
//[Authorize(Roles = "Admin")] public IActionResult Index() { var profiles = _userService.GetAll() .OrderByDescending(user => user.Rating) .Select(u => new ProfileListModel { Id = u.Id, FirstName = u.LastName, ProfileImageUrl = u.ProfileImageUrl, UserRating = u.Rating.ToString(), MemberSince = u.MemberSince }); var model = new ProfileIndexModel { Profiles = profiles }; return(View(model)); }
public ActionResult Index(int?id, int?page) { var customer = _customerService.GetCustomerById(id ?? 0); if (!_customerSettings.AllowViewingProfiles || (customer == null || customer.IsGuest())) { return(HttpNotFound()); } var name = customer.FormatUserName(_customerSettings, T, true); var model = new ProfileIndexModel { Id = customer.Id, ProfileTitle = T("Profile.ProfileOf", name), PostsPage = page ?? 0, PagingPosts = page.HasValue, ForumsEnabled = _forumSettings.ForumsEnabled }; return(View(model)); }
public async Task <IActionResult> Index(string username) { var profileModel = await this.userService.GetUserByUsernameAsync <ProfileViewModel>(username); if (profileModel == null) { return(this.Redirect("/error")); } var userId = await this.userService.GetIdByUserName(username); var friends = await this.friendService.GetAllFriendsByUserIdAsync <ShortUserViewModel>(userId); var images = await this.imageService.GetAllImageByUserId <ImageViewModel>(userId); var model = new ProfileIndexModel() { ViewModel = profileModel, Friends = friends.ToList(), Images = images.ToList(), }; return(this.View(model)); }
public async Task <IActionResult> Index(int id, int?page) { var customer = await _db.Customers.FindByIdAsync(id, false); if (!_customerSettings.AllowViewingProfiles || customer == null || customer.IsGuest()) { return(NotFound()); } var name = customer.FormatUserName(_customerSettings, T, true); var model = new ProfileIndexModel { Id = customer.Id, ProfileTitle = T("Profile.ProfileOf", name), //PostsPage = page ?? 0, //PagingPosts = page.HasValue, //ForumsEnabled = _forumSettings.ForumsEnabled }; // INFO: (mh) (core) Model preparation for old Info action starts here. // TODO: (mh) (core) Make prepare model method so we dont always must refer to model.ProfileInfo... model.ProfileInfo.Id = id; model.ProfileInfo.Avatar = customer.ToAvatarModel(null, true); // Location. if (_customerSettings.ShowCustomersLocation) { model.ProfileInfo.LocationEnabled = true; var country = await _db.Countries.FindByIdAsync(customer.GenericAttributes.CountryId ?? 0); if (country != null) { model.ProfileInfo.Location = country.GetLocalized(x => x.Name); } else { model.ProfileInfo.LocationEnabled = false; } } // TODO: (mh) (core) Forum module must handle this somehow. Also ask if forum is enabled (because now PMs can be sent even if the Forum is turned off). // Private message. //model.ProfileInfo.PMEnabled = _forumSettings.AllowPrivateMessages && !customer.IsGuest(); // TODO: (mh) (core) Forum module must handle this somehow. // Total forum posts. //if (_forumSettings.ForumsEnabled && _forumSettings.ShowCustomersPostCount) //{ // model.TotalPostsEnabled = true; // model.TotalPosts = customer.GetAttribute<int>(SystemCustomerAttributeNames.ForumPostCount, _genericAttributeService); //} // Registration date. if (_customerSettings.ShowCustomersJoinDate) { model.ProfileInfo.JoinDateEnabled = true; model.ProfileInfo.JoinDate = _dateTimeHelper.ConvertToUserTime(customer.CreatedOnUtc, DateTimeKind.Utc).ToString("f"); } // Birth date. if (_customerSettings.DateOfBirthEnabled && customer.BirthDate.HasValue) { model.ProfileInfo.DateOfBirthEnabled = true; model.ProfileInfo.DateOfBirth = customer.BirthDate.Value.ToString("D"); } return(View(model)); }
public ActionResult CustomerProfile(ProfileIndexModel model) { var customerId = model.CustomerProfileId; //increment view count _customerProfileViewService.IncrementViewCount(customerId); //get customer object var customer = _customerService.GetCustomerById(customerId); if (customer == null) { return(null); } var profile = _customerProfileService.GetByCustomerId(customerId); var customerSeName = SeoExtensions.GetSeName(customer, _workContext.WorkingLanguage.Id, true, false); var profilemodel = new CustomerProfilePublicModel() { CustomerId = customerId, ViewCount = _customerProfileViewService.GetViewCount(customerId), FriendCount = _customerProfileService.GetFriendCount(customerId), CustomerName = customer.GetFullName(), SeName = customerSeName, ProfileUrl = Url.RouteUrl("CustomerProfileUrl", new { SeName = customerSeName }), ProfileImageUrl = _pictureService.GetPictureUrl(customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId), _mediaSettings.AvatarPictureSize, true), CoverImageUrl = _pictureService.GetPictureUrl(customer.GetAttribute <int>(AdditionalCustomerAttributeNames.CoverImageId)), ProfileIndexModel = model }; if (_workContext.CurrentCustomer.Id == customerId) { profilemodel.FriendStatus = FriendStatus.Self; profilemodel.IsEditable = true; } else { //depending on who is viewing the profile, let's set the friend status and other relevent values var customerFriend = _friendService.GetCustomerFriendship(_workContext.CurrentCustomer.Id, customer.Id); if (customerFriend == null) { profilemodel.FriendStatus = FriendStatus.None; } else if (customerFriend.Confirmed) { profilemodel.FriendStatus = FriendStatus.Friends; } else if (!customerFriend.Confirmed && customerFriend.FromCustomerId == _workContext.CurrentCustomer.Id) { profilemodel.FriendStatus = FriendStatus.FriendRequestSent; } else { profilemodel.FriendStatus = FriendStatus.NeedsConfirmed; } } //and the follower counts & logged in user following status var followers = _customerFollowService.GetFollowers <CustomerProfile>(customerId); profilemodel.FollowingStatus = followers.Any(x => x.CustomerId == _workContext.CurrentCustomer.Id) ? 1 : 0; profilemodel.FollowerCount = followers.Count; return(View("mobSocial/CustomerProfile/Profile", profilemodel)); }