public UserBlackListViewModel(User user) { if (user == null) return; BlackList = user.BlackList.Select(x => new UserBlackList_UserViewModel(x)).ToList(); }
public _BadgesViewModel(User user) { if (user != null) Badges = user.Badges.Where(x => x.IsAcquired).Select(x => new BadgeViewModel(x)).ToList(); else Badges = new List<BadgeViewModel>(); }
public AlbumsViewModel(User user, Group group) { GroupAlbums = new List<AlbumViewModel>(); UserAlbums = new List<AlbumViewModel>(); CreateGroupAlbum = new AlbumCreateEditViewModel(); CreateUserAlbum = new AlbumCreateEditViewModel(); if (group != null) { GroupId = group.Id; GroupAlbums = group.Albums.Select(x => new AlbumViewModel(x)).ToList(); CreateGroupAlbum = new AlbumCreateEditViewModel(group); } if (user != null) { UserId = user.Id; UserAlbums = user.Albums.Select(x => new AlbumViewModel(x)).ToList(); CreateUserAlbum = new AlbumCreateEditViewModel(user); } Albums = GroupAlbums.Union(UserAlbums).ToList(); }
public UserDraftsViewModel(User user) { if (user != null) { var drafts = DataService.PerThread.ContentSet.Where(p => p.AuthorId == user.Id && p.State == (byte)ContentState.Draft); AuthorId = user.Id; AuthorName = user.FullName; IList<Post> posts = drafts.OfType<Post>().ToList(); IList<Survey> surveys = drafts.OfType<Survey>().ToList(); IList<Petition> petitions = drafts.OfType<Petition>().ToList(); Posts = posts.Select(x => new UserDrafts_ContentViewModel(x)).ToList(); Surveys = surveys.Select(x => new UserDrafts_ContentViewModel(x)).ToList(); Petitions = petitions.Select(x => new UserDrafts_PetitionViewModel(x)).ToList(); CoauthorPetitions = new List<UserDrafts_PetitionViewModel>(); IList<Coauthor> coauthors = DataService.PerThread.CoauthorSet .Where(c => c.UserId == user.Id && c.IsAccepted.HasValue).Where(c => c.IsAccepted.Value).ToList(); foreach (var coauthor in coauthors) if (coauthor.Petition.State == (byte)ContentState.Draft) CoauthorPetitions.Add(new UserDrafts_PetitionViewModel(coauthor.Petition)); } }
public UserInvitesViewModel(User user) { if (user != null) Invites = user.Invites .OrderByDescending(x => x.CreationDate).Select(x => new UserInvites_InviteViewModel(x)).ToList(); else Invites = new List<UserInvites_InviteViewModel>(); }
public UserQuestViewModel(User user) { if (user != null) { UserId = user.Id; QuestProgress = (QuestProgress)user.QuestProgress; } }
public UserTrashMessagesViewModel(User user) { var inbox = user.InboxMessages.Where(x => x.IsDeletedByRecipient); var outbox = user.OutboxMessages.Where(x => x.IsDeletedByAuthor); var messages = inbox.Union(outbox).ToList(); Messages = messages.Select(x => new UserMessageViewModel(x)).OrderByDescending(x => x.Date).ToList(); }
public UserBlackList_UserViewModel(User user) { if (user == null) return; Id = user.Id; FullName = user.FullName; Avatar = ImageService.GetImageUrl<User>(user.Avatar); }
public UserCommentsViewModel(User user, bool? invert = null) { if (user != null) { UserId = user.Id; UserFullName = user.FullName; Comments = new _CommentsViewModel(user, invert); } }
public UserEditSubscription_GroupViewModel(Group group, User user) { Logo = ImageService.GetImageUrl<Group>(group.Logo); Name = group.Name; Url = group.Url; var uig = GroupService.UserInGroup(user.Id, group.Id); UserIsMember = uig != null; }
public void SubscribeToGroup(Group group, User subscriber, bool saveChanges) { if (!subscriber.SubscriptionGroups.Contains(group)) { subscriber.SubscriptionGroups.Add(group); if (saveChanges) DataService.PerThread.SaveChanges(); } }
public UserViewModel(User user) { if (user != null) { Avatar = ImageService.GetImageUrl<User>(user.Avatar); Id = user.Id; FirstName = user.FirstName; SurName = user.SurName; Patronymic = user.Patronymic; } }
public UserSubscriptionViewModel(User user) { UserId = user.Id; UserName = user.FullName; IsEmailVerified = user.IsEmailVerified; IsSubscribed = user.SubscriptionSettings.IsSubscribed; SubscriptionEmail = user.SubscriptionSettings.SubscriptionEmail; if (!IsEmailVerified) VerificationEmailSendDate = AccountService.IsEmailVerificationAlreadySend(user.Id); }
public UserGroupsViewModel(User user) { if (user != null) { GMs = new List<UserGroups_GroupMemberViewModel>(); UserName = user.FullName; UserId = user.Id; foreach (var gm in user.GroupMembers.Where(x => x.State == (byte)GroupMemberState.Approved || x.State == (byte)GroupMemberState.Moderator || x.State == (byte)GroupMemberState.NotApproved).OrderByDescending(x => x.Group.GroupMembers.Count)) GMs.Add(new UserGroups_GroupMemberViewModel(gm)); } }
public Group_Moders_ItemViewModel(User user = null) { if (user != null) { Id = user.Id; Name = user.FirstName; Surname = user.SurName; if (user.Address != null) City = user.Address.City.Title; Avatar = ImageService.GetImageUrl<User>(user.Avatar); } }
public static void SendPassword(string code, string phone, User user) { var url = ConstHelper.ApiUrl + "sendpassword"; var data = new { ApiKey = ConstHelper.ApiKey, Phone = phone, Code = code }; SendJson(url, data); }
public AccountTicketVerificationViewModel(User user) { if (user == null) return; if (!string.IsNullOrEmpty(user.PhoneNumber)) PhoneNumber = user.PhoneNumber; FullName = user.FullName; BirthDate = user.BirthDate; IsTicketVerified = user.IsTicketVerified; }
public UserEditContactsViewModel(User user) { Facebook = user.Facebook; LiveJournal = user.LiveJournal; LJPublishState = user.LiveJournalSindicateAsDraft; LJSindication = user.LiveJournalSindication; if (string.IsNullOrWhiteSpace(Facebook)) IsFbEditable = true; if (string.IsNullOrWhiteSpace(LiveJournal)) IsLjEditable = true; }
private void FixupUser(User previousValue) { if (previousValue != null && ReferenceEquals(previousValue.MailRecord, this)) { previousValue.MailRecord = null; } if (User != null) { User.MailRecord = this; } }
private void FixupUser(User previousValue) { if (previousValue != null && ReferenceEquals(previousValue.SubscriptionSettings, this)) { previousValue.SubscriptionSettings = null; } if (User != null) { User.SubscriptionSettings = this; } }
public UserVotersViewModel(User user, bool isForeignProfile) { IsForeignProfile = isForeignProfile; if (user == null) return; UserId = user.Id; Groups = user.GroupMembers .Where(x => x.Expert != null).Select(x => new UserVoters_GroupViewModel(x.Group, x.Expert, user.Id)) .ToList(); }
public UserBlogViewModel(User user, Guid? currentUid = null) { if (user == null) return; UserId = user.Id; UserFullName = user.FullName; if (currentUid.HasValue && user.BlackList.Count(x => x.Id == currentUid.Value) == 0) IsPMAllow = true; var feed = user.Contents.Where(x => x.State == (byte)ContentState.Approved && x.PublishDate.HasValue).OrderByDescending(x => x.PublishDate); Feed = new _ContentFeedViewModel(feed, user.Id); }
public void NormalizePhoneNumber(User user, bool saveChanges) { if (user.PhoneNumber == null) return; var phone = Regex.Replace(user.PhoneNumber, @"\D*", string.Empty); var phoneLength = phone.Length; if (phoneLength < 10) { user.PhoneNumber = null; user.IsPhoneVerified = false; user.IsForeigner = false; } else if (phoneLength == 10) { user.PhoneNumber = '7' + phone; user.IsForeigner = false; } else if (phoneLength == 11) { var codes2 = new[] { "81", "82", "84", "86" }; var codes3 = new[] { "800", "808", "850", "852", "853", "855", "856", "870", "878", "880", "881", "882", "886" }; if (phone[0] == '7') { user.PhoneNumber = phone; user.IsForeigner = false; } else if (phone[0] == '8' && !codes2.Contains(phone.Substring(0, 2)) && !codes3.Contains(phone.Substring(0, 3))) { user.PhoneNumber = '7' + phone.Remove(0, 1); user.IsForeigner = false; } else { user.PhoneNumber = phone; user.IsForeigner = true; } } else { user.PhoneNumber = phone; user.IsForeigner = true; } if (saveChanges) DataService.PerThread.SaveChanges(); }
public UserProfileChangeRequestViewModel(User user) { if (user != null) { UserId = user.Id; UserName = user.FullName; Firstname = user.FirstName; Surname = user.SurName; Patronymic = user.Patronymic; Facebook = user.Facebook; LiveJournal = user.LiveJournal; PhoneNumber = user.PhoneNumber; } }
public User_ContactsViewModel(User user) { UserId = user.Id; LiveJournal = user.LiveJournal; if (LiveJournal != null) { if (!LiveJournal.Contains("http:")) LiveJournal = "http://" + LiveJournal; } var facebookAccount = user.SocialAccounts.SingleOrDefault(x=>x.SocialType == (byte)SocialType.Facebook); if (facebookAccount != null) { Facebook = facebookAccount.DirectUrl; } }
public _CommentsViewModel(User user, bool? invert = null) { if (user != null) { Invert = invert; UserId = user.Id; var comments = user.Comments.Where(x => !x.IsHidden); if (invert.HasValue && invert.Value) comments = comments.OrderBy(c => c.DateTime); else comments = comments.OrderByDescending(c => c.DateTime); Comments = comments.ToPaginationList(ConstHelper.CommentsPerPage, x => new _Comments_CommentViewModel(x)); } }
public static void D2SendPassword(string code, string phone, User user) { var url = ConstHelper.ApiUrl + "d2sendpassword"; var data = new { ApiKey = ConstHelper.ApiKey, Phone = phone, Code = code, FirstName = user.FirstName, Patronymic = user.Patronymic, SurName = user.SurName, BirthDate = user.BirthDate }; SendJson(url, data); }
public UserEditAvatarViewModel(User user) { AvatarImageName = user.Avatar; AvatarUrl = ImageService.GetImageUrl<User>(user.Avatar); if (AvatarUrl == ConstHelper.DefaultImageName) HasAvatar = false; else { HasAvatar = true; var size = ImageService.GetImageSize<User>(user.Avatar); ImageWidth = size.Width; ImageHeight = size.Height; } }
public UserEditViewModel(User user) { if (user != null) { Avatar = ImageService.GetImageUrl<User>(user.Avatar); Facebook = user.Facebook; FullName = user.FullName; Name = user.FirstName; Patronymic = user.Patronymic; SurName = user.SurName; Info = user.Info; LiveJournal = user.LiveJournal; IsVerified = user.IsVerified; if (user.Address != null) City = user.Address.City.Title; BirthDate = user.BirthDate; if (user.BirthDate.HasValue) { var diff = DateTime.Now.Year - user.BirthDate.Value.Year; Age = DeclinationService.OfNumber((diff + (user.BirthDate.Value <= DateTime.Now.AddYears(-diff) ? 0 : -1)), "год", "года", "лет"); } if (user.BirthAddress != null) { switch (user.BirthAddress.City.Type) { case (byte)CityType.City: BirthCity = "г. "; break; case (byte)CityType.Settlement: BirthCity = "п. "; break; case (byte)CityType.Village: BirthCity = "с. "; break; } BirthCity += user.BirthAddress.City.Title; } } }
public UserProfileViewModel(User user) { if (user == null) return; FullName = user.FullName; UserId = user.Id; Info = TextHelper.CleanTags(user.Info); CommentsCount = user.Comments.Count(x => !x.IsHidden); IsTicketVerified = user.IsTicketVerified; if (user.BirthAddress != null) { switch (user.BirthAddress.City.Type) { case (byte)CityType.City: BirthCity = "г. "; break; case (byte)CityType.Settlement: BirthCity = "п. "; break; case (byte)CityType.Village: BirthCity = "с. "; break; } BirthCity += user.BirthAddress.City.Title; } BirthDate = user.BirthDate; UTCOffset = new TimeSpan(0, user.UTCOffset, 0); if (user.BirthDate.HasValue) { var diff = DateTime.Now.Year - user.BirthDate.Value.Year; Age = DeclinationService.OfNumber((diff + (user.BirthDate.Value <= DateTime.Now.AddYears(-diff) ? 0 : -1)), "год", "года", "лет"); } Contacts = new User_ContactsViewModel(user); DraftsCount = user.Contents.Count(x => x.State == (byte)ContentState.Draft); Badges = new _BadgesViewModel(user); }