Ejemplo n.º 1
0
        public async Task <IEnumerable <StatusModel> > GetAllSavedAsync(StatusListParamsModel statusListParams)
        {
            if (statusListParams == null)
            {
                throw new ArgumentNullException("statusListParams");
            }

            var mapper        = new StatusMapper();
            var paramsMapper  = new StatusListParamsMapper();
            var paramsModel   = paramsMapper.Map(statusListParams, new StatusListParams());
            var savedStatuses = await this.statusStoreRepository.GetAllSavedAsync(paramsModel);

            var statusModels = savedStatuses.Select(x => mapper.Map(x, new StatusModel())).ToList();

            statusModels.ForEach(x =>
            {
                x.IsSaved   = true;
                x.CreatedAt = x.CreatedAt.ToLocalTime();
            });

            return(statusModels);
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <StatusModel> > GetUserTimelineAsync(StatusListParamsModel statusListParams)
        {
            if (statusListParams == null)
            {
                throw new ArgumentNullException("statusListParams");
            }

            var mapper       = new StatusMapper();
            var paramsMapper = new StatusListParamsMapper();
            var paramsModel  = paramsMapper.Map(statusListParams, new StatusListParams());
            var statuses     = await this.statusRepository.GetUserTimelineAsync(paramsModel);

            var statusModels = statuses
                               .Select(x => mapper.Map(x, new StatusModel()))
                               .ToList();

            var savedStatusIds = await this.statusStoreRepository.GetSavedStatusIdsAsync();

            var savedStatusIdsList = savedStatusIds.ToList();

            statusModels.ForEach(x => x.IsSaved = savedStatusIdsList.Contains(x.Id));

            return(statusModels);
        }