public static Expert CreateExpertWithoutSaving(GroupMember expertGroupMember) { var expert = new Expert { GroupMember = expertGroupMember }; DataService.PerThread.ExpertSet.AddObject(expert); return expert; }
public UserVoters_GroupViewModel(Group group, Expert expert, Guid userId) { if (group == null) return; Name = group.Name; Url = group.Url; Logo = ImageService.GetImageUrl<Group>(group.Logo); ExpertId = expert.Id.ToString(); var expertGroupMember = GroupService.UserInGroup(userId, group); GroupMember userGroupMember = null; if(UserContext.Current != null) userGroupMember = GroupService.UserInGroup(UserContext.Current.Id, group); VotersCount = DataService.PerThread.ExpertVoteSet.Where(x => x.ExpertId == expert.Id).GroupBy(x => x.GroupMemberId).Count(); ExpertTags = expertGroupMember.Expert.Tags.Select(x => new TagViewModel(x)).ToList(); foreach (var tag in ExpertTags) { tag.IsChecked = false; if (userGroupMember!= null && userGroupMember.ExpertVotes.Count(x => x.TagId == tag.Id) > 0) tag.IsChecked = true; } }
public static Expert CreateExpertWithoutSaving(GroupMember expertGroupMember) { var expert = new Expert { GroupMember = expertGroupMember }; DataService.PerThread.ExpertSet.AddObject(expert); return(expert); }
private void FixupExpert(Expert previousValue) { if (previousValue != null && ReferenceEquals(previousValue.GroupMember, this)) { previousValue.GroupMember = null; } if (Expert != null) { Expert.GroupMember = this; } }
public SearchTag_ExpertViewModel(Expert expert) { if (expert != null) { Avatar = ImageService.GetImageUrl<User>(expert.GroupMember.User.Avatar); GroupName = expert.GroupMember.Group.Name; GroupUrl = expert.GroupMember.Group.Url; GroupLogo = ImageService.GetImageUrl<Group>(expert.GroupMember.Group.Logo); Name = expert.GroupMember.User.FullName; FirstName = expert.GroupMember.User.FirstName; SurName = expert.GroupMember.User.SurName; Patronymic = expert.GroupMember.User.Patronymic; Tags = expert.Tags.Select(x => new TagViewModel(x)).ToList(); UserId = expert.GroupMember.UserId; } }
private void FixupExpert(Expert previousValue) { if (previousValue != null && previousValue.ExpertVotes.Contains(this)) { previousValue.ExpertVotes.Remove(this); } if (Expert != null) { if (!Expert.ExpertVotes.Contains(this)) { Expert.ExpertVotes.Add(this); } if (ExpertId != Expert.Id) { ExpertId = Expert.Id; } } }
public UserSelfExpertDelegate_ExpertViewModel(Expert expert) { if (expert != null) { Avatar = ImageService.GetImageUrl<User>(expert.GroupMember.User.Avatar); Id = expert.Id; Info = expert.Info; Name = expert.GroupMember.User.FullName; UserId = expert.GroupMember.UserId; } }
public GroupTopicExperts_ItemViewModel(Expert expert, Guid topicId, int totalCount, Guid? votedExpertId = null) { ExpertId = expert.Id; var user = DataService.PerThread.BaseUserSet.OfType<User>().SingleOrDefault(x => x.GroupMembers.Any(g => g.Expert.Id == expert.Id)); if (user != null) { Id = user.Id; FullName = user.FullName; Image = ImageService.GetImageUrl<User>(user.Avatar); } Description = ""; if (!string.IsNullOrEmpty(expert.Info)) Description = Regex.Replace(expert.Info, @"(\r?\n\s{0,}){1,}", "<br/>"); if (Description.Length > 300) Description = Description.Substring(0, 300) + "..."; VotesCount = expert.ExpertVotes.Count(x => x.TagId == topicId); if (totalCount > 0) VotesRelative = Math.Round(((double)VotesCount) / totalCount, 2); else VotesRelative = 0; VoteDelegated = votedExpertId == expert.Id; }
public GroupExperts_ExpertViewModel(Expert expert) { Id = expert.Id; UserId = expert.GroupMember.UserId; var user = expert.GroupMember.User; Avatar = ImageService.GetImageUrl<User>(user.Avatar); FirstName = user.FirstName; SurName = user.SurName; Patronymic = user.Patronymic; foreach (var tag in expert.Tags) Tags.Add(new TagViewModel(tag)); }
public Group_Experts_ExpertViewModel(Expert expert) { if (expert != null) { var user = expert.GroupMember.User; Id = expert.Id; UserId = user.Id; Name = user.FirstName; Surname = user.SurName; if (user.Address != null) City = user.Address.City.Title; Avatar = ImageService.GetImageUrl<User>(user.Avatar); Weight = DataService.PerThread.ExpertVoteSet.Count(x => x.ExpertId == expert.Id); } }