public async Task <ActionResult> Details(int userId) { var user = await UserManager.FindByIdAsync(userId); var currentUser = User.Identity.IsAuthenticated ? await GetCurrentUserAsync() : null; var userProfileViewModel = new UserProfileViewModel() { DisplayName = user.DisplayName, ThisUserProjects = user.ProjectAcls, UserId = user.UserId, Reason = currentUser != null ? (AccessReason)user.GetProfileAccess(currentUser) : AccessReason.NoAccess, Details = UserProfileDetailsViewModel.FromUser(user), HasAdminAccess = currentUser?.Auth?.IsAdmin ?? false, IsAdmin = user.Auth?.IsAdmin ?? false }; if (currentUser != null) { userProfileViewModel.CanGrantAccessProjects = currentUser.GetProjects(acl => acl.CanGrantRights); userProfileViewModel.Claims = new ClaimListViewModel(currentUser.UserId, user.Claims.Where(claim => claim.HasAnyAccess(currentUser.UserId)).ToArray(), null, showCount: false, showUserColumn: false); } return(View(userProfileViewModel)); }
public CheckInClaimModel([NotNull] Claim claim, [NotNull] User currentUser, [CanBeNull] IReadOnlyCollection <PlotElement> plotElements) { if (claim == null) { throw new ArgumentNullException(nameof(claim)); } if (currentUser == null) { throw new ArgumentNullException(nameof(currentUser)); } Validator = new ClaimCheckInValidator(claim); CheckInTime = claim.CheckInDate; ClaimStatus = (ClaimStatusView)claim.ClaimStatus; PlayerDetails = new UserProfileDetailsViewModel(claim.Player, (AccessReason)claim.Player.GetProfileAccess(currentUser)); Navigation = CharacterNavigationViewModel.FromClaim(claim, currentUser.UserId, CharacterNavigationPage.None); CanAcceptFee = claim.Project.CanAcceptCash(currentUser); ClaimId = claim.ClaimId; ProjectId = claim.ProjectId; Master = claim.ResponsibleMasterUser; Handouts = plotElements?.Where(e => e.ElementType == PlotElementType.Handout && e.IsActive) .Select(e => e.PublishedVersion()) .Where(e => e != null) .Select(e => new HandoutListItemViewModel(e.Content.ToPlainText(), e.AuthorUser)) .ToArray() ?? new HandoutListItemViewModel [] {}; NotFilledFields = Validator.NotFilledFields .Select(frp => new NotFilledFieldViewModel( frp.Field.CanPlayerEdit ? NotFilledFieldViewModel.WhoWllFillEnum.Player : NotFilledFieldViewModel.WhoWllFillEnum.Master, frp.Field.FieldName)).ToList(); CurrentUserFullName = currentUser.FullName; }
return(new SubscribeListViewModel() { User = new UserProfileDetailsViewModel(data.User, currentUser), AllowChanges = data.User == currentUser, //TODO allow project admins to setup subscribe for other masters Items = data.UserSubscriptions.Select(x => x.ToViewModel(uriService)).ToArray(), ProjectId = projectId, PaymentTypeNames = paymentTypes.Select(pt => pt.ToPaymentTypeName()).ToArray(), });
public SecondRoleViewModel(Claim claim, IEnumerable <Character> characters, User currentUser) { Master = claim.ResponsibleMasterUser; Navigation = CharacterNavigationViewModel.FromClaim(claim, currentUser.UserId, CharacterNavigationPage.None); PlayerDetails = new UserProfileDetailsViewModel(claim.Player, AccessReason.Master); ClaimId = claim.ClaimId; Characters = characters.Select( c => new CharacterListItemViewModel() { Id = c.CharacterId.ToString(), Name = c.CharacterName, Master = ResponsibleMasterExtensions.GetResponsibleMaster(c)?.GetDisplayName() ?? "нет", }); }
// GET: UserProfiles/users/{userAddress}/ public ActionResult Details(string userAddress) { if (userAddress == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var userProfile = _userProfileService.GetUserProfileByUserAddress(userAddress); if (userProfile == null) { return(HttpNotFound()); } var relativePath = "~/Content/avatars/" + userProfile.Id + "_avatar.jpg"; var absolutePath = HttpContext.Server.MapPath(relativePath); if (System.IO.File.Exists(absolutePath)) { userProfile.AvatarUrl = "../../Content/avatars/" + userProfile.Id + "_avatar.jpg"; } else { userProfile.AvatarUrl = "../../Content/avatars/default_avatar.jpeg"; } var currentUserProfile = _userProfileService.GetUserProfileByUserId(new Guid(User.Identity.GetUserId())); var friendRequest = _friendRequestService.CheckIfFriendRequestExists(currentUserProfile.Id, userProfile.Id); var viewModel = new UserProfileDetailsViewModel { Profile = userProfile, FriendsCollection = _userProfileService.GetUserProfileFriends(userProfile.Id), ActiveFriendRequest = friendRequest }; if (viewModel.FriendsCollection == null) { viewModel.FriendsCollection = new Friends { Friend_UserProfile = new Collection <UserProfile>(), UserProfile = new UserProfile() }; } return(View(viewModel)); }
public ActionResult Create(UserProfileDetailsViewModel userProfile) //[Bind(Include = "Name, Description")] { try { if (ModelState.IsValid) { var userProfileDto = Mapper.Map <UserProfileDetailsViewModel, UserProfileTransferModel>(userProfile); _userProfileService.SaveUserProfile(userProfileDto); return(RedirectToAction("Index")); } } catch (RetryLimitExceededException /* dex */) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } catch (ValidationException ex) { ModelState.AddModelError("Email", ex.Message); }; ViewBag.DirectionId = GetDirections(); return(View(userProfile)); }
// GET: UserProfile/Details //[Route("UserProfile/Details", Name = "ReturnDetails"), HttpGet] public ActionResult Details(string UserName) { var user = UserManager.FindByName(User.Identity.Name); Service service = new Service(); var userProfile = service.GetProfileInfoByUserName(UserName); var jeepProfile = service.GetPrimaryJeepInfo(UserName); service.UpdateViewCount(UserName); UserProfileDetailsViewModel model = new UserProfileDetailsViewModel(); model.FirstName = userProfile.FirstName; model.LastName = userProfile.LastName; model.BirthDate = userProfile.BirthDate; model.Facebook = userProfile.Facebook; model.GooglePlus = userProfile.GooglePlus; model.Ello = userProfile.Ello; model.Website = userProfile.Website; model.Instagram = userProfile.Instagram; model.Description = userProfile.Description; model.ViewCount = userProfile.ViewCount == null ? 0 : userProfile.ViewCount; model.Avatar = userProfile.Avatar; model.UserName = UserName; model.UserPosts = service.GetAllPostsForUser(UserName); model.RecentPost = service.GetUsersMostRecentPost(UserName); model.BlockedUsers = service.BlockedUsers(UserName); model.AllowedUsers = service.AllowedUsers(UserName); model.Settings = service.GetSettingsByUserName(UserName); model.UsersStatus = service.GetStatusForUser(UserName); if (jeepProfile != null) { model.Year = jeepProfile.Year; model.JeepDescription = jeepProfile.Description; model.Make = jeepProfile.Make; model.Model = jeepProfile.Model; model.Image = jeepProfile.Image; } return(View(model)); }
public async Task <IActionResult> Profile(int id) { if (id == 0) { return(NotFound()); } User user = await userService.GetByIDAsync(id); if (user == null || user.UserProfile == null) { return(NotFound()); } UserProfileVisibility userProfileVisibility = await userProfileVisibilityService.GetByUserProfileIDAsync(user.UserProfile.ID); if (userProfileVisibility == null) { return(NotFound()); } UserProfileCommentPermission userProfileCommentPermission = await userProfileCommentPermissionService.GetByIDAsync((int)user.UserProfile.UserProfileCommentPermissionID); if (userProfileCommentPermission == null) { return(NotFound()); } UserProfileDetailsViewModel viewModel = new UserProfileDetailsViewModel { UserProfile = user.UserProfile, User = user, UserProfileComments = user.UserProfileCommentsCreated.ToList(), UserProfileVisibility = userProfileVisibility, UserProfileCommentPermission = userProfileCommentPermission }; return(View(viewModel)); }
public async Task <UserProfileDetailsViewModel> UserProfile(LoginViewModel model) { try { const string spName = "dbo.UserProfile_Select"; using (var cn = new SqlConnection(DbWebConfigConnectionClass.ConnectionString)) { cn.Open(); using (var cmd = new SqlCommand(spName, cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Username", model.Username); var rdr = await cmd.ExecuteReaderAsync(CommandBehavior.Default); var data = new UserProfileDetailsViewModel(); if (!rdr.Read()) { //TODO update database with failed login throw new InvalidOperationException("No records match that username."); } data.UserId = rdr.GetString(rdr.GetOrdinal("UserId")); data.FirstName = rdr.GetString(rdr.GetOrdinal("FirstName")); data.LastName = rdr.GetString(rdr.GetOrdinal("LastName")); data.PasswordHash = rdr.GetString(rdr.GetOrdinal("PasswordHash")); return(data); } } } catch (SqlException e) { throw new ApplicationException(e.ToString()); } catch (Exception e) { throw new ApplicationException(e.ToString()); } }