Ejemplo n.º 1
0
        public async Task <List <Result> > UpdateUserFilterAsync(Filter filter)
        {
            var currentFilter = await _dbClient.GetBaseFilterForForumOnUserIdAsync(filter.UserId);

            if (currentFilter == null)
            {
                var newFilter = new Database.Entities.User.Filter
                {
                    UserId          = filter.UserId,
                    PostsPerPage    = filter.PostsPerPage,
                    HideLeftMenu    = filter.HideLeftMenu,
                    HideRightMenu   = filter.HideRightMenu,
                    ExcludedUserIds = string.Join(",", filter.ExcludedUsers.Select(x => x.Key))
                };
                return(await new List <Result>().Get(_dbClient.CreateBaseFilterForForumOnUserAsync(newFilter),
                                                     ResultMessages.ChangeFilter));
            }

            currentFilter.PostsPerPage    = filter.PostsPerPage;
            currentFilter.ExcludedUserIds = string.Join(",", filter.ExcludedUsers.Select(x => x.Key));
            currentFilter.HideLeftMenu    = filter.HideLeftMenu;
            currentFilter.HideRightMenu   = filter.HideRightMenu;

            return(await new List <Result>().Get(_dbClient.UpdateBaseFilterForForumOnUserAsync(currentFilter),
                                                 ResultMessages.ChangeFilter));
        }
Ejemplo n.º 2
0
 public Filter Convert(Database.Entities.User.Filter source, Filter destination, ResolutionContext context)
 {
     return(new Filter
     {
         UserId = source.UserId,
         PostsPerPage = source.PostsPerPage,
         HideLeftMenu = source.HideLeftMenu,
         HideRightMenu = source.HideRightMenu,
         ExcludedUsers = !string.IsNullOrEmpty(source.ExcludedUserIds) ? source.ExcludedUserIds?.Split(",")
                         .Select(userId => new KeyValuePair <string, string>(userId, _userRepository.GetCurrentNickOnUserIdAsync(userId).Result)) : new List <KeyValuePair <string, string> >()
     });
 }