Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Master.selected = "default";
     string connectionString = ConfigurationManager.ConnectionStrings["iPortendConnectionString"].ConnectionString;
     Facebook.Schema.user u = Master.Api.Users.GetInfo();
     string userid = u.uid.ToString();
     string username = u.first_name;
     lblInfo.Text = "Welcome to iPortend beta!" + "  uid = " + userid + " name = " + username;
     //CheckExist(userID);
     PredictionRepository repo = new PredictionRepository();
     var FaceUser = repo.CheckUser(userid);
     if (FaceUser.Count() == 0)
     {
         PreMembership member = new PreMembership();
         member.UserId = new Guid();
         member.UserType = 1;
         member.UserFaceID = u.uid.ToString();
         repo.AddUser(member);
         repo.Save();
     }
     Category.DataSource = repository.categoryList();
     Category.DataTextField = "Description";
     Category.DataValueField = "CategoryID";
     Category.DataBind();
     
 }
Exemplo n.º 2
0
 public IHttpActionResult Get(int competitionSeasonId, int fixtureId)
 {
     try
     {
         // Only want to return the predictions if the fixture is completed for this controller
         var fixture = FixtureRepository.Get(fixtureId);
         if (fixture == null)
         {
             return(BadRequest("The fixture does not exist"));
         }
         if (!fixture.Completed)
         {
             return(BadRequest("The fixture has not been completed"));
         }
         else
         {
             var predictions = PredictionRepository.GetByCompetitionSeasonFixture(competitionSeasonId, fixtureId);
             return(Ok(predictions));
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Exemplo n.º 3
0
        //PROFILE PAGE
        public IActionResult Profile(string username)
        {
            try
            {
                User u = repo.GetUser(username);
                if (u != null)
                {
                    u.Friends                    = repo.GetAcceptedFriends(u.ID);
                    ViewBag.LoggedInUser         = repo.GetUser(HttpContext.Session.GetString("Account"));
                    ViewBag.LoggedInUser.Friends = repo.GetAcceptedFriends(ViewBag.LoggedInUser.ID);

                    ViewBag.ProfileType = DetermineProfileType(u, ViewBag.LoggedInUser);
                    PredictionRepository tempRepo = new PredictionRepository(new PredictionRepositorySQLContext());
                    ViewBag.Predictions = tempRepo.GetAllPredictions(u);
                    return(View(u));
                }
                else
                {
                    return(View("UserNotFound"));
                }
            }
            catch (Exception)
            {
                return(View("Error"));
            }
        }
 public IHttpActionResult Get(int competitionSeasonId)
 {
     try
     {
         // Get the competition season object to work with
         var competitionSeason = CompetitionSeasonRepository.Get(competitionSeasonId);
         // Get all of the players from the competition season
         var players = PlayerRepository.GetAllByCompetitionSeason(competitionSeasonId);
         // For each of the players get the completed fixture closed predictions and create a ranking object
         var rankings = new List <IRanking>();
         foreach (var player in players)
         {
             player.Predictions = PredictionRepository.GetByCompetitionSeasonPlayer(competitionSeasonId, player.Id);
             var completedClosedPredictions = player.GetCompletedClosedPredictions();
             var liveClosedPredictions      = player.GetLiveClosedPredictions();
             var combinedPredictions        = new List <IClosedPrediction>();
             combinedPredictions.AddRange(liveClosedPredictions);
             combinedPredictions.AddRange(completedClosedPredictions);
             //combinedPredictions.AddRange(liveClosedPredictions);
             var ranking = new Ranking(player.User.FullName, combinedPredictions, competitionSeason);
             rankings.Add(ranking);
         }
         Ranking.OrderRankings(rankings);
         return(Ok(rankings));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Exemplo n.º 5
0
        //public PredictionServiceTests()
        //{
        //    var predictionRepository = new Mock<IPredictionRepository>();
        //    predictionRepository.Setup(x => x.CheckTypeResult(It.IsAny<string>())).ReturnsAsync((string result) =>
        //   {
        //       if (Convert.ToInt32(result.Substring(0, 1)) > Convert.ToInt32(result.Substring(2, 1))) return TypeResult.WinTeam1;
        //       else if (Convert.ToInt32(result.Substring(0, 1)) < Convert.ToInt32(result.Substring(2, 1))) return TypeResult.WinTeam2;
        //       else if (Convert.ToInt32(result.Substring(0, 1)) == Convert.ToInt32(result.Substring(2, 1))) return TypeResult.Draw;
        //       else return TypeResult.NNB;
        //   });

        //    predictionRepository.Setup(x => x.CompareResultsAsync(It.IsAny<Game>(), It.IsAny<Prediction>())).ReturnsAsync((Game z, Prediction y) =>
        //   {
        //       if (y.PredictedResult == z.Result)
        //           return 3;
        //       else if (y.PredictedTypeResult == z.typeResult)
        //           return 1;
        //       else
        //           return 0;
        //   });
        //    _predictionService = new PredictionService(predictionRepository.Object);
        //}

        public async Task CreateDb()
        {
            var options = new DbContextOptionsBuilder <StrikeNetDbContext>()
                          .UseInMemoryDatabase(databaseName: "StrikeNetTestDb")
                          .EnableSensitiveDataLogging()
                          .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
                          .Options;

            var dbContext = new StrikeNetDbContext(options);

            if (await dbContext.Predictions.CountAsync() <= 0)
            {
                Prediction p1 = new Prediction()
                {
                    Id                  = 1,
                    GameId              = 1,
                    UserId              = User1,
                    PredictedResult     = "3-0",
                    PredictedTypeResult = TypeResult.WinTeam1
                };
                Prediction p2 = new Prediction()
                {
                    Id                  = 2,
                    GameId              = 3,
                    UserId              = User2,
                    PredictedResult     = "2-0",
                    PredictedTypeResult = TypeResult.WinTeam1
                };
                Prediction p3 = new Prediction()
                {
                    Id                  = 3,
                    GameId              = 3,
                    UserId              = User3,
                    PredictedResult     = "0-1",
                    PredictedTypeResult = TypeResult.WinTeam2
                };
                Prediction p4 = new Prediction()
                {
                    Id                  = 4,
                    GameId              = 4,
                    UserId              = User4,
                    PredictedResult     = "1-1",
                    PredictedTypeResult = TypeResult.Draw
                };
                dbContext.Predictions.Add(p1);
                dbContext.Predictions.Add(p2);
                dbContext.Predictions.Add(p3);
                dbContext.Predictions.Add(p4);
                await dbContext.SaveChangesAsync();
            }

            var identityRepository   = new IdentityRepository(_userManager, _roleManager, _signInManager);
            var predictionRepository = new PredictionRepository(identityRepository, dbContext);

            _predictionService2 = new PredictionService(predictionRepository);
        }
Exemplo n.º 6
0
 public IHttpActionResult Get(int competitionSeasonId, int playerId)
 {
     try
     {
         var player      = PlayerRepository.Get(playerId);
         var predictions = PredictionRepository.GetByCompetitionSeasonPlayer(competitionSeasonId, playerId);
         player.Predictions = predictions;
         return(Ok(player));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
 public IHttpActionResult Get(int competitionSeasonId, int playerId)
 {
     try
     {
         var player = PlayerRepository.Get(playerId);
         player.Predictions = PredictionRepository.GetByCompetitionSeasonPlayer(competitionSeasonId, playerId);
         var closedPredictions = player.GetLiveClosedPredictions();
         // Get the points scored for each of the predictions
         var competitionSeason = CompetitionSeasonRepository.Get(competitionSeasonId);
         return(Ok(closedPredictions));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Exemplo n.º 8
0
        public async Task CreateDbWithMockIdentity()
        {
            var options = new DbContextOptionsBuilder <StrikeNetDbContext>()
                          .UseInMemoryDatabase(databaseName: "StrikeNetTestDb")
                          .EnableSensitiveDataLogging()
                          .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
                          .Options;

            var _dbContext = new StrikeNetDbContext(options);

            TestUser = new UserIdentity {
                Score = 0
            };
            var identityRepository = new Mock <IIdentityRepository>();

            identityRepository.Setup(x => x.GetUserAsync(It.IsAny <Guid?>())).ReturnsAsync(TestUser);
            var predictionRepository = new PredictionRepository(identityRepository.Object, _dbContext);

            _predictionService = new PredictionService(predictionRepository);
        }
 public PredictionController(PredictionRepository repository)
 {
     this._repository = repository;
 }
Exemplo n.º 10
0
 public PredictionService()
 {
     repoCow             = new CowRepository();
     notificationService = new NotificationService();
     predictionRepo      = new PredictionRepository();
 }