예제 #1
0
        public bool CheckUser(int idUser, DateTime dateVote)
        {
            List <VoteModel> votes           = _votationData.GetVotesByDate(dateVote);
            bool             hasAlreadyVoted = votes.Any(row => row.IdUser.Equals(idUser));

            if (hasAlreadyVoted)
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        public List <ReturnVotesModel> GetVotes(DateTime date)
        {
            List <ReturnVotesModel> resultVotes = new List <ReturnVotesModel>();

            var votesDate = _votationData.GetVotesByDate(date);

            var restaurants = votesDate.GroupBy(x => x.IdRestaurant);

            foreach (var restaurant in restaurants)
            {
                resultVotes.Add(new ReturnVotesModel()
                {
                    RestaurantName = _restaurantData.GetById(restaurant.Key).Name,
                    Votes          = votesDate.FindAll(x => x.IdRestaurant == restaurant.Key).Count()
                });;
            }

            return(resultVotes);
        }