/// <summary>
        /// Method GetAll return all votings.
        /// </summary>
        /// <returns>Lists of votings entity.</returns>
        public IEnumerable <VotingEntity> GetAll()
        {
            try {
                return(votingRepository.GetAll().Select(vote => vote.ToBllVoting()));
            }
            catch (Exception ex) {
                logger.Error(logger.GetMessage("Get all votes was failed.", this), ex);
            }

            return(null);
        }
Пример #2
0
        public async Task <List <VotingDto> > GetAllVoting(SieveModel sieve)
        {
            var votings = _votingRepository.GetAll();

            votings = _sieveProcessor.Apply(sieve, votings);
            votings = votings.Include(v => v.Category);

            List <VotingDto> votingList = new List <VotingDto>();

            foreach (var item in votings)
            {
                votingList.Add(new VotingDto
                {
                    ID          = item.ID,
                    Name        = item.Name,
                    Category    = item.Category.Name,
                    Description = item.Description,
                    CreatedDate = item.CreatedDate,
                    DueDate     = item.DueDate,
                    VotersCount = item.VotersCount
                });
            }

            return(votingList);
        }