Beispiel #1
0
        public void Create(string leagueId, TeamViewModel model)
        {
            var exitedIds = model.Members
                .Where(x => !string.IsNullOrEmpty(x.Id))
                .Select(x => x.Id);
            var userEntities = model.Members
                .Where(x => string.IsNullOrEmpty(x.Id))
                .Select(x => new UserDb {Name = x.Name})
                .ToList();
            _playersRepository.AddRange(leagueId, userEntities);

            var userIds = userEntities.Select(x => x.EntityId);
            var memberIds = exitedIds.Concat(userIds);

            var entity = new TeamDb
            {
                LeagueId = leagueId,
                Name = model.Name,
                Hidden = model.Hidden,
                MemberIds = memberIds,
                MediaId = model.Media,
                Description = model.Description
            };
            _teamsRepository.Add(leagueId, entity);
        }
        public TeamInfoStatisticViewModel(TeamStatisticsViewModel model, TeamDb team)
        {
            this.LeagueName = team.Name;

            this.Id = model.Id;
            this.GamesCount = model.GamesCount;
            this.Wins = model.Wins;
            this.Loses = model.Loses;
            this.Draws = model.Draws;
            this.Scores = model.Scores;
            this.Missed = model.Missed;
            this.Points = model.Points;
        }