Ejemplo n.º 1
0
        public void AddSameTeam()
        {
            TeamDTO boca = new TeamDTO()
            {
                Name      = "Boca",
                SportName = "Futbol"
            };
            TeamServices services = new TeamServices(login, teamRepository, sportRepository, userRepository);

            services.CreateTeam(boca);
            services.CreateTeam(boca);
        }
Ejemplo n.º 2
0
        public void RecoverAllFollowedTeams()
        {
            ILoginServices loginServices = new LoginServices(userRepo, teamRepo);
            IUserServices  userServices  = new UserServices(loginServices, userRepo, teamRepo, sportRepo);
            ITeamServices  teamServices  = new TeamServices(loginServices, teamRepo, sportRepo, userRepo);
            ISportServices sportServices = new SportServices(loginServices, sportRepo);

            loginServices.CreateSession("sSanchez", "user");

            TeamDTO cavaliers = new TeamDTO()
            {
                Name      = "Cavaliers",
                Logo      = EncondeImage(Image.FromFile(GetResourcePath("Cavaliers.jpg"))),
                SportName = "Baskteball"
            };
            SportDTO basketball = new SportDTO()
            {
                Name = "Baskteball"
            };

            TeamDTO team = new TeamDTO()
            {
                Name      = "Cavaliers",
                Logo      = EncondeImage(Image.FromFile(GetResourcePath("Cavaliers.jpg"))),
                SportName = "Baskteball"
            };

            sportServices.CreateSport(basketball);
            teamServices.CreateTeam(team);
            teamServices.AddFollowedTeam("Cavaliers_Baskteball");

            IEnumerable <TeamDTO> followedTeams = userServices.GetFollowedTeams();

            Assert.AreEqual(cavaliers.Name, followedTeams.First().Name);
        }
        public ActionResult Create(TeamViewModel team)
        {
            if (ModelState.IsValid)
            {
                team.Continent = continentServices.ReturnContinent(team.ViewContinentId);
                teamServices.CreateTeam(team);
                return(RedirectToAction("Index"));
            }

            return(View(team));
        }
Ejemplo n.º 4
0
        public void DeleteTeamWithoutSufficientPermission()
        {
            login = new LoginServicesMock(christina);
            TeamServices services = new TeamServices(login, teamRepository, sportRepository, userRepository);
            TeamDTO      boca     = new TeamDTO()
            {
                Name = "Boca", SportName = "Futbol"
            };

            services.CreateTeam(boca);
            services.DeleteTeam("Boca");
        }
Ejemplo n.º 5
0
        private async void BtnFinish_Clicked(object sender, EventArgs e)
        {
            if (!App.Current.Properties.ContainsKey("loggedUser"))
            {
                await DisplayAlert("HATA", "Lütfen giriş yapınız", "Tamam");

                await Navigation.PushAsync(new LoginPageMain());
            }
            else if (App.Current.Properties["loggedUserTeamPlayer"] != null)
            {
                await DisplayAlert("HATA", "Bir hata oluştu", "OK");

                App.Current.Properties.Remove("loggedUserTeamPlayer");
                App.Current.Properties.Remove("loggedUser");
                App.Current.MainPage = new NavigationPage(new IndexTabbedPages.IndexPageMain());
            }
            else
            {
                if (isSuccessName == false || isSuccessShortName == false)
                {
                    await DisplayAlert("UYARI", "Lütfen takım adını ve kısaltmasını kontrol edin", "Tamam");
                }
                else
                {
                    try
                    {
                        await Navigation.PushPopupAsync(new AnimationPopUpPage1_Waiting("Oluşturuluyor.."));

                        CreateTeamModel modelToReturn = await serviceTeam.CreateTeam(entryTeamName.Text, entryTeamShortName.Text, "abc");

                        await Navigation.PopPopupAsync();

                        if (modelToReturn.isSuccesful == true)
                        {
                            await DisplayAlert("Başarılı", modelToReturn.responseMessage, "OK");

                            App.Current.Properties["loggedUserTeamPlayer"] = modelToReturn.TeamPlayer;
                            App.Current.MainPage = new NavigationPage(new IndexPageMain());
                        }
                        else
                        {
                            await DisplayAlert("Hata", modelToReturn.responseMessage, "OK");
                        }
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public void AddTeamOk()
        {
            TeamDTO boca = new TeamDTO
            {
                Name      = "Boca",
                SportName = "Futbol"
            };
            TeamServices services = new TeamServices(login, teamRepository, sportRepository, userRepository);

            services.CreateTeam(boca);
            IEnumerable <Team> recovered = teamRepository.GetAll();

            Assert.AreEqual(1, recovered.ToList().Count);
        }
Ejemplo n.º 7
0
        public void FollowTeam()
        {
            ILoginServices loginServices = new LoginServicesMock(pepe);
            ITeamServices  teamServices  = new TeamServices(loginServices, teamRepo, sportRepo, userRepo);
            ISportServices sportServices = new SportServices(loginServices, sportRepo);

            SportDTO basketball = new SportDTO()
            {
                Name = "Basketball"
            };

            sportServices.CreateSport(basketball);

            TeamDTO cavaliers = new TeamDTO()
            {
                Name      = "Cavaliers",
                Logo      = EncondeImage(Image.FromFile(GetResourcePath("Cavaliers.jpg"))),
                SportName = "Basketball"
            };

            teamServices.CreateTeam(cavaliers);
            userRepo.Add(new User()
            {
                UserName = pepe.UserName,
                Name     = pepe.Name,
                Surname  = pepe.Surname,
                Mail     = pepe.Mail,
                Password = pepe.Password,
                Role     = pepe.IsAdmin ? Role.Administrator : Role.Follower
            });
            userRepo.Add(new User()
            {
                UserName = pablo.UserName,
                Name     = pablo.Name,
                Surname  = pablo.Surname,
                Mail     = pablo.Mail,
                Password = pablo.Password,
                Role     = pablo.IsAdmin ? Role.Administrator : Role.Follower
            });
            loginServices = new LoginServicesMock(pablo);
            teamServices.AddFollowedTeam("Cavaliers_Basketball");

            User        recovered     = userRepo.Get(pepe.UserName);
            List <Team> followedTeams = recovered.FollowedTeams.ToList();

            Assert.IsTrue(followedTeams.First().Name == "Cavaliers");
        }
Ejemplo n.º 8
0
        public void DeleteTeamOk()
        {
            TeamDTO boca = new TeamDTO()
            {
                Name = "Boca", SportName = "Futbol"
            };

            SportServices sportServices = new SportServices(login, sportRepository);
            TeamServices  teamServices  = new TeamServices(login, teamRepository, sportRepository, userRepository);

            teamServices.CreateTeam(boca);

            teamServices.DeleteTeam("Boca_Futbol");

            IEnumerable <Team> recovered = teamRepository.GetAll();

            Assert.AreEqual(0, recovered.ToList().Count);
        }