Example #1
0
        public IEnumerable <EncounterDTO> GetAllEncountersWithFollowedTeams()
        {
            List <Encounter>        encountersWithComment = new List <Encounter>();
            IEnumerable <Encounter> allEncounters         = encounterRepository.GetAll();

            foreach (var encounter in allEncounters)
            {
                bool intersect   = encounter.Teams.Select(t => t.Name.ToString()).Intersect(loginServices.LoggedUser.FollowedTeamsNames).Any();
                bool hasComments = (encounter.Comments.Any());

                if (intersect && hasComments)
                {
                    encountersWithComment.Add(encounter);
                }
            }

            return(encountersWithComment.Select(e => encounterMapper.Map(e)));
        }
Example #2
0
        public IEnumerable <EncounterDTO> CreateFixture(string fixtureGeneratorName, string sportName, DateTime startDate)
        {
            adminValidator.ValidatePermissions();
            ValidateSportIsTwoPlayerSport(sportName);
            IFixtureGenerator       generatorServices = GetFixtureGenerator(fixtureGeneratorName, sportName);
            IEnumerable <Team>      teamsInSport      = teamRepo.GetAll().Where(t => t.Sport.Name == sportName);
            ICollection <Encounter> encounters        = generatorServices.GenerateFixture(teamsInSport, startDate);

            ValidateFixture(encounters);
            SaveEncounters(encounters);
            return(encounters.Select(e => mapper.Map(e)));
        }
Example #3
0
 public EncounterDTO CreateEncounter(EncounterDTO encounterDTO)
 {
     try
     {
         adminValidator.ValidatePermissions();
         Encounter encounter = mapper.Map(encounterDTO);
         ValidateNonOverlappingOfDates(encounter);
         encounterRepository.Add(encounter);
         return(mapper.Map(encounter));
     }
     catch (DataAccessException e)
     {
         throw new ServicesException(e.Message, e);
     }
     catch (DomainException e)
     {
         throw new ServicesException(e.Message, e);
     }
 }
Example #4
0
        public void CreateSimpleEncounter()
        {
            login.CreateSession("sSanchez", "user");

            EncounterSimpleServices encounterSimpleServices = new EncounterSimpleServices(login, encounterRepo, sportRepo, teamRepo, userRepo, commentRepo);
            IEnumerable <Team>      teams = new List <Team> {
                atenas, wanderers
            };
            DateTime date = new DateTime(3018, 10, 07);

            Encounter expected = new Encounter(futbol, teams, date);

            encounterSimpleServices.CreateEncounter(mapper.Map(expected));

            List <Encounter> recovered = encounterRepo.GetAll().ToList();

            Assert.IsTrue(recovered.Contains(expected));
        }
 public Encounter ToModel()
 {
     return(mapper.Map(this));
 }