Пример #1
0
        public static NewsListViewModels ToViewModel(this ListWithTotalDTO dto)
        {
            NewsListViewModels model = null;

            if (dto != null)
            {
                IEnumerable <NewsItemViewModels> list = new List <NewsItemViewModels>();
                if (dto.List != null)
                {
                    list = dto.List.Cast <News>().Select(x => new NewsItemViewModels()
                    {
                        Id    = x.Id.ToString(),
                        Img   = x.ImagePath,
                        Tilte = x.Title,
                        Text  = x.Summary
                    });
                }

                model = new NewsListViewModels()
                {
                    Total = dto.Total,
                    List  = list
                };
            }


            return(model);
        }
Пример #2
0
        public static EventListViewModel ToEventsListViewModel(this ListWithTotalDTO dto)
        {
            EventListViewModel model = null;

            if (dto != null)
            {
                IEnumerable <EventListItemViewModel> list = new List <EventListItemViewModel>();
                if (dto.List != null)
                {
                    list = dto.List.Cast <Event>().Select(x => new EventListItemViewModel()
                    {
                        Id          = x.Id.ToString(),
                        DateStart   = x.DateStart.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"),
                        DateEnd     = x.DateEnd.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"),
                        Location    = x.Location,
                        Title       = x.Title,
                        Description = x.Description
                    });
                }

                model = new EventListViewModel()
                {
                    Total = dto.Total,
                    List  = list
                };
            }


            return(model);
        }
Пример #3
0
        public Task <ListWithTotalDTO> GetPagedNewsWithTotalAsync(int skip, int take, CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            IQueryable <News> all = this._newsRepository.GetAllElements();
            var result            = new ListWithTotalDTO()
            {
                Total = all.Count(),
                List  = all.Skip(skip).Take(take)
            };

            return(Task.FromResult <ListWithTotalDTO>(result));
        }
Пример #4
0
        public Task<ListWithTotalDTO> GetPagedEventsWithTotalAsync(int skip, int take, CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            IQueryable<Event> all = this._evntRepository.GetAllElements();
            var result = new ListWithTotalDTO()
            {
                Total = all.Count(),
                List = all.Skip(skip).Take(take)
            };

            return Task.FromResult<ListWithTotalDTO>(result);
        }