コード例 #1
0
        public UserBlackListViewModel(User user)
        {
            if (user == null)
                return;

            BlackList = user.BlackList.Select(x => new UserBlackList_UserViewModel(x)).ToList();
        }
コード例 #2
0
 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>();
 }
コード例 #3
0
ファイル: AlbumsViewModel.cs プロジェクト: arbium/democratia2
        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();
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
 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>();
 }
コード例 #6
0
 public UserQuestViewModel(User user)
 {
     if (user != null)
     {
         UserId = user.Id;
         QuestProgress = (QuestProgress)user.QuestProgress;
     }
 }
コード例 #7
0
        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();
        }
コード例 #8
0
        public UserBlackList_UserViewModel(User user)
        {
            if (user == null)
                return;

            Id = user.Id;
            FullName = user.FullName;
            Avatar = ImageService.GetImageUrl<User>(user.Avatar);
        }
コード例 #9
0
 public UserCommentsViewModel(User user, bool? invert = null)
 {
     if (user != null)
     {
         UserId = user.Id;
         UserFullName = user.FullName;
         Comments = new _CommentsViewModel(user, invert);
     }
 }
コード例 #10
0
        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;
        }
コード例 #11
0
        public void SubscribeToGroup(Group group, User subscriber, bool saveChanges)
        {
            if (!subscriber.SubscriptionGroups.Contains(group))
            {
                subscriber.SubscriptionGroups.Add(group);

                if (saveChanges)
                    DataService.PerThread.SaveChanges();
            }
        }
コード例 #12
0
ファイル: UserViewModel.cs プロジェクト: arbium/democratia2
 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;
     }
 }
コード例 #13
0
        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);
        }
コード例 #14
0
        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));
            }
        }
コード例 #15
0
 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);
     }
 }
コード例 #16
0
ファイル: ApiService.cs プロジェクト: arbium/democratia2
        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);
        }
コード例 #17
0
        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;
        }
コード例 #18
0
        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;
        }
コード例 #19
0
ファイル: MailRecord.cs プロジェクト: arbium/democratia2
        private void FixupUser(User previousValue)
        {
            if (previousValue != null && ReferenceEquals(previousValue.MailRecord, this))
            {
                previousValue.MailRecord = null;
            }

            if (User != null)
            {
                User.MailRecord = this;
            }
        }
コード例 #20
0
        private void FixupUser(User previousValue)
        {
            if (previousValue != null && ReferenceEquals(previousValue.SubscriptionSettings, this))
            {
                previousValue.SubscriptionSettings = null;
            }

            if (User != null)
            {
                User.SubscriptionSettings = this;
            }
        }
コード例 #21
0
        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();
        }
コード例 #22
0
        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);
        }
コード例 #23
0
ファイル: UserServiceImpl.cs プロジェクト: arbium/democratia2
        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();
        }
コード例 #24
0
        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;
            }
        }
コード例 #25
0
        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;
            }
        }
コード例 #26
0
        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));
            }
        }
コード例 #27
0
ファイル: ApiService.cs プロジェクト: arbium/democratia2
        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);
        }
コード例 #28
0
        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;
            }
        }
コード例 #29
0
        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;
                }
            }
        }
コード例 #30
0
        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);
        }