public GroupMember GetGroupMember(long userId, bool createIfNeeded)
 {
     var groupMember = _groupMemberRepository.GroupMember(userId);
     if (groupMember == null && createIfNeeded)
     {
         var users = _usersApi.Get(new List<long> { userId });
         foreach (var userDto in users)
         {
             groupMember = new GroupMember
                                   {
                                       Name = userDto.Name,
                                       SywId = userDto.Id
                                   };
             _groupMemberRepository.AddOrSaveNewGroupMember(groupMember);
         }
     }
     return groupMember;
 }
        private ShopGroupHomeScreenModel ToModel(GroupMember groupMember, UserDto userDto,ProductDto product, ShopGroup group )
        {
            return new ShopGroupHomeScreenModel
                {
                    Id = userDto.Id,
                    MemberName = userDto.Name,
                    ImageUrl = userDto.ImageUrl,
                    Product = product,
                    Group = group,
                    Token = _platformTokenProvider.Get(),
                    ProfileUrl = new Uri(_platformSettings.SywWebSiteUrl, userDto.ProfileUrl),
                    Followers = _usersApi.GetFollowers(userDto.Id),

                    ShopGroups = groupMember != null ?
                            groupMember.Groups :
                            null
                };
        }
        private void AddUserToDataBase()
        {
            var user = _usersApi.Current();
            var token = _platformTokenProvider.Get();
            if(_groupMemberRepository.GroupMember((int)user.Id) != null) return;

            var groupMember = new GroupMember { Name = user.Name, SywId = (int)user.Id, Token = token};
            _groupMemberRepository.AddOrSaveNewGroupMember(groupMember);
        }
 public void SendWallPsotToFriends(ShopGroup group, GroupMember member)
 {
     throw new NotImplementedException();
 }
Esempio n. 5
0
        public virtual void AddMember(GroupMember member)
        {
            if (Members.Contains(member)) return;

            Members.Add(member);
            member.Groups.Add(this);
        }
 public void AddOrSaveNewGroupMember(GroupMember member)
 {
     _sessionProvider.WithSession(session => session.SaveOrUpdateCopy(member));
 }