Ejemplo n.º 1
0
        public Clubs GetAll()
        {
            var items = _clubRepository.GetAll().Select(c => new ClubItem
            {
                Id   = c.Id,
                Name = c.Name
            });

            var clubs = new Clubs
            {
                Items = items.ToList()
            };

            return(clubs);
        }
Ejemplo n.º 2
0
        public ClubList GetAll()
        {
            var clubs           = _clubRepository.GetAll().ToList();
            var gameProcessList = new ClubList();

            foreach (var club in clubs)
            {
                var clubItem = new ClubItem
                {
                    Id   = club.Id,
                    Name = club.Name
                };

                var gameProcesses = _gameProcessRepository.GetAll().Where(c => c.ClubId == club.Id).ToList();

                foreach (var gameProcess in gameProcesses)
                {
                    var gameProcessItems = GetGameProcessItems(gameProcess);

                    var totalInput  = gameProcessItems.SelectMany(c => c.Input.Select(i => i.Amount).ToList()).Sum();
                    var totalOutput = gameProcessItems.Where(c => c.OutPut != null).Select(c => c.OutPut.Amount).Sum();

                    var subtract = !gameProcess.EndDateTime.HasValue
                        ? DateTime.Subtract(gameProcess.StartDateTime.GetValueOrDefault())
                        : gameProcess.EndDateTime.Value.Subtract(gameProcess.StartDateTime.GetValueOrDefault());

                    var item = new GameProcessListItem
                    {
                        Id           = gameProcess.Id,
                        DateTime     = gameProcess.StartDateTime.GetValueOrDefault(),
                        DirationTime = subtract,
                        PlayerCount  = gameProcessItems.Count,
                        TotalInput   = totalInput,
                        TotalOutput  = totalOutput,
                        Total        = (totalInput - totalOutput),
                        IsFinish     = gameProcess.EndDateTime.HasValue
                    };
                    clubItem.Items.Add(item);
                }

                clubItem.PlayersCount = clubItem.Items.Sum(c => c.PlayerCount);
                clubItem.Total        = clubItem.Items.Sum(c => c.Total);

                gameProcessList.Clubs.Add(clubItem);
            }

            return(gameProcessList);
        }
Ejemplo n.º 3
0
        public IEnumerable <Club> GetClubs()
        {
            var repo = new ClubRepository();

            return(repo.GetAll());
        }