Пример #1
0
        public IHttpActionResult CreateTeams(CreateTeamModel model)
        {
            var players = _dbContext.Players
                          .Where(w => model.Guids.Contains(w.Guid))
                          .ToList();

            var teams = _creationService.CreateTeams(players, new List <Team> {
                new Team {
                    Name = "Blanc"
                }, new Team {
                    Name = "Orange"
                }
            });

            var viewModel = teams.Select(s => new TeamViewModel
            {
                Guid    = s.Guid,
                Name    = s.Name,
                Players = s.Players.Select(p => new PlayerViewModel
                {
                    FirstName    = p.FirstName,
                    Guid         = p.Guid,
                    GradeEnum    = p.Grade,
                    LastName     = p.LastName,
                    PositionEnum = p.Position,
                    PhoneNumber  = p.PhoneNumber
                }).ToList()
            }).ToList();

            return(Ok(viewModel));
        }
        public void Test_Create_TwoTeams()
        {
            var teams = new List <Team>
            {
                new Team
                {
                    Name = "Orange"
                },
                new Team
                {
                    Name = "Blanc"
                }
            };


            var result = _service.CreateTeams(DataHelper.Players(), teams);

            Assert.AreEqual(result.First().Players.Count, result.Last().Players.Count);
        }