public bool ToggleVote(int id, int categoryID, string userID, bool actual, out string message)
        {
            message = string.Empty;
            var category = CategoryService.Get(categoryID);

            if (category.Statut != (int)Common.Entities.CategoryStatus.Opened)
            {
                message = "La catégorie est fermée aux votes";
                return(false);
            }
            if (actual)
            {
                RankingService.RemoveVote(id, userID);
                message = "Votre vote a bien été annulé !";
                return(true);
            }

            int nbVotes = RankingService.GetNumberVotesForUser(categoryID, userID);

            if (nbVotes >= Constants.MAX_VOTES)
            {
                message = "Désolé, vous avez atteint le maximum de votes";
                return(false);
            }
            if (RankingService.AddVote(id, userID))
            {
                message = "Merci pour votre vote !";
                return(true);
            }
            else
            {
                message = "Vous avez déjà voté pour cet album";
                return(false);
            }
        }
Example #2
0
        public async Task MainAsync()
        {
            using var services = ConfigureServices();
            _client            = services.GetRequiredService <DiscordSocketClient>();
            _ranking           = services.GetRequiredService <RankingService>();
            _config            = services.GetRequiredService <ConfigService>();
            _joinEvent         = services.GetRequiredService <UserJoinEvent>();
            _data     = services.GetRequiredService <DataService>();
            _auditer  = services.GetRequiredService <AuditService>();
            _manager  = services.GetRequiredService <RoleService>();
            _database = services.GetRequiredService <DatabaseService>();

            _client.Log   += Log;
            _client.Ready += OnReady;
            await _client.SetGameAsync("the door", type : ActivityType.Watching);

            await _client.LoginAsync(TokenType.Bot, _config.BotConfig.Token);

            await _client.StartAsync();

            await services.GetRequiredService <CommandHandlerService>().InstallCommandsAsync();

            // Block this task until the program is closed.
            await Task.Delay(-1);
        }
Example #3
0
        public HomeViewModel GetHomeViewModel()
        {
            var viewModel = new HomeViewModel();
            List <DAL.Model.Category> categories = CategoryService.GetPopulaires();

            foreach (var category in categories.Take(3))
            {
                viewModel.Populaires.Add(new CategoryCardViewModel
                {
                    Category = category,
                    Top      = RankingService.GetTop3ByCategoryID(category.CategoryID)
                });
            }

            List <DAL.Model.Category> newCategories = CategoryService.GetNewest();

            foreach (var category in newCategories.Take(3))
            {
                viewModel.Nouvelles.Add(new CategoryCardViewModel
                {
                    Category = category,
                    Top      = RankingService.GetTop3ByCategoryID(category.CategoryID)
                });
            }
            return(viewModel);
        }
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            Results = await RankingService.ComputeResultList($"{Id}/{Stage}");

            Competition = RankingService.Competition;
        }
Example #5
0
        public List <Ranking> GetRankingList(int scheduleId)
        {
            var service = new RankingService(new RankingRepository());
            var errors  = new List <string>();

            //// we could log the errors here if there are any...
            return(service.GetRankings(scheduleId, ref errors));
        }
 public HomeController(BookService bookService, UserService userService, RatingService ratingService,
                       UserManager <IdentityUser> userManager, RankingService rankingService)
 {
     this.bookService    = bookService;
     this.userService    = userService;
     this.ratingService  = ratingService;
     this.userManager    = userManager;
     this.rankingService = rankingService;
 }
Example #7
0
        private void LoadComboBoxRanking()
        {
            RankingService = new RankingService();
            var rankings = RankingService.All();

            foreach (var Ranking in rankings)
            {
                CBClassificacao.Items.Add(Ranking.Name);
            }
        }
        public void RankingErrorTest()
        {
            //// Arranage
            var errors         = new List <string>();
            var mockRepository = new Mock <IRankingRepository>();
            var rankingService = new RankingService(mockRepository.Object);

            //// Act
            rankingService.GetRankingInfo(null, -1, ref errors);

            //// Assert
            Assert.AreEqual(2, errors.Count);
        }
        public void InsertRankingErrorTest()
        {
            //// Arrange
            var errors            = new List <string>();
            var mockRepository    = new Mock <IRankingRepository>();
            var enrollmentService = new RankingService(mockRepository.Object);

            //// Act
            enrollmentService.InsertRanking(null, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
Example #10
0
        public ClassementViewModel GetClassementViewModel()
        {
            var viewModel = new ClassementViewModel();

            foreach (var category in CategoryService.GetPopulaires())
            {
                viewModel.AllPopulaires.Add(new CategoryCardViewModel
                {
                    Category = category,
                    Top      = RankingService.GetTop3ByCategoryID(category.CategoryID)
                });
            }

            return(viewModel);
        }
Example #11
0
        public override async Task LoadAllAsync()
        {
            try
            {
                RankingService service = new RankingService();

                IEnumerable <Ranking> rankings = await service.GetAllAsync();

                Rankings.ReplaceWith(rankings);
            }
            catch
            {
                throw;
            }
        }
Example #12
0
        public SurveyController()
        {
            this.modelContext = new ModelContext();

            var userStore = new UserStore <ApplicationUser>(this.modelContext);
            var roleStore = new RoleStore <ApplicationRole>(this.modelContext);

            this.userManager = new UserManager <ApplicationUser>(userStore);
            this.roleManager = new RoleManager <ApplicationRole>(roleStore);

            this.surveyCompletionByDemandEmailService = new SurveyCompletionByDemandEmailService();
            this.pdfService                 = new PdfService();
            this.rankingService             = new RankingService();
            this.surveyService              = new SurveyService();
            this.evaluationService          = new EvaluationService();
            this.sendEmailToContinueService = new SendEmailToContinueService();
        }
        public RankingTests()
        {
            var levels = new[]
            {
                new Level()
                {
                    Id = 1, ExpRequired = 0, Name = "Default"
                }
            };
            var users = new[]
            {
                new User()
                {
                    Email    = "*****@*****.**",
                    UserName = "******"
                }
            };
            var players = new[]
            {
                new Player()
                {
                    CurrentMission = null, Description = "Halo!", Exp = 110, Name = "Mateusz Bąkała", Id = 1,
                    UserImage      = new byte[] { 3 }, Level = levels[0], User = users[0]
                }
            };

            player = players[0];
            var mockContext = new Mock <CityGamesContext>()
            {
                CallBase = true
            };

            mockContext.Setup(c => c.Players).ReturnsDbSet(players);
            mockContext.Setup(c => c.Levels).ReturnsDbSet(levels);
            var             mockUnitOfWork = MockHelper.MockUnitOfWork(mockContext.Object);
            IRankingService service        = new RankingService(mockUnitOfWork.Object);

            controller = new RankingController(service);

            var mockC = new Mock <HttpControllerContext>();

            controller.ControllerContext = mockC.Object;
            controller.ControllerContext.RequestContext.Principal = new GenericPrincipal(new GenericIdentity("bakalam", "Type"), new string[] { });
            controller.Configuration = new HttpConfiguration();
            controller.Request       = new HttpRequestMessage();
        }
        public void InsertRankingErrorTest2()
        {
            //// Arranage
            var errors         = new List <string>();
            var mockRepository = new Mock <IRankingRepository>();
            var rankingService = new RankingService(mockRepository.Object);
            var ranking        = new Ranking
            {
                StudentId  = string.Empty,
                ScheduleId = -1,
                Rank       = -1
            };

            //// Act
            rankingService.InsertRanking(ranking, ref errors);

            //// Assert
            Assert.AreEqual(3, errors.Count);
        }
        private void btn_Zerar_Click(object sender, EventArgs e)
        {
            var senha = Ferramentas.getMD5Hash(txt_Senha.Text);

            if (senha == "67f683b2b9d5b0eecfe46f0d9119961d" && radioMes.Checked)
            {
                RankingService.Resetar(ERanking.Mensal);
                MessageBox.Show("O ranking mensal foi resetado com sucesso", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (senha == "496f366709619f761f5802d1ece99e7d" && radioAnual.Checked)
            {
                RankingService.Resetar(ERanking.Anual);
                MessageBox.Show("O ranking anual foi resetado com sucesso", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Senha inválida", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #16
0
        public async Task <ActionResult <List <DsRankingResponse> > > GetRanking()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            List <DsRankingResponse> rankings;

            if (!memoryCache.TryGetValue("Ranking", out rankings))
            {
                rankings = await RankingService.GetRanking(context);

                memoryCache.Set("Ranking", rankings, CacheService.BuildCacheOptions);
                sw.Stop();
                logger.LogInformation($"Got Rankings in {sw.ElapsedMilliseconds} ms");
            }
            else
            {
                sw.Stop();
                logger.LogInformation($"Got Rankings from Cache in {sw.ElapsedMilliseconds} ms");
            }
            return(rankings);
        }
        private List <VoteAlbumViewModel> GetAlbumsList(int categoryID, string userID)
        {
            var rankingAlbums  = RankingService.GetRankingAlbumsByCategoryID(categoryID);
            var votedAlbumsIDs = AlbumService.GetAlbumsVotedByCategoryIDAndUserID(categoryID, userID).Select(a => a.AlbumID);

            var votedAlbums = rankingAlbums.Where(ra => votedAlbumsIDs.Contains(ra.AlbumID)).Select(ra => new VoteAlbumViewModel
            {
                Album      = ra,
                IsUserVote = true
            }).ToList();

            var notVotedAlbums = rankingAlbums.Where(ra => !votedAlbumsIDs.Contains(ra.AlbumID)).Select(ra => new VoteAlbumViewModel
            {
                Album      = ra,
                IsUserVote = false
            }).ToList();


            votedAlbums.AddRange(notVotedAlbums);

            return(votedAlbums);
        }
Example #18
0
 public RankingsModule(IServiceProvider provider)
 {
     _rankings = provider.GetRequiredService <RankingService>();
     _log      = provider.GetRequiredService <LoggingService>();
     _client   = provider.GetRequiredService <DiscordSocketClient>();
 }
Example #19
0
 public FRMClassificacao()
 {
     InitializeComponent();
     service = new RankingService();
     LoadDataGridRanking();
 }
Example #20
0
 public bool Vote(int album_id, string userID)
 {
     return(RankingService.Vote(album_id, userID));
 }
 public RankingController(RankingService rankingService, RatingService ratingService)
 {
     this.rankingService = rankingService;
     this.ratingService  = ratingService;
 }
Example #22
0
 public void RankingService_GetRankings_Throws_On_Invalid_ContentItemId()
 {
     ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => RankingService.GetRankings(Null.NullInteger));
 }
Example #23
0
 public void RankingService_UpdateRanking_Throws_On_Null_Ranking()
 {
     AutoTester.ArgumentNull <Ranking>(marker => RankingService.UpdateRanking(marker));
 }
Example #24
0
 public SongListController(SongService service, RankingService rankingService, SongListQueries queries)
 {
     this.service        = service;
     this.rankingService = rankingService;
     this.queries        = queries;
 }
 public RankingsController(RankingService rankingService)
 {
     this.rankingService = rankingService;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="rankingService">Serviço de CRUD ao banco</param>
 public RankingController(RankingService rankingService)
 {
     _ranking = rankingService;
 }
Example #27
0
 private Ranking GetRankingSelectByName()
 {
     RankingService = new RankingService();
     return(RankingService.GetSingleByName(CBClassificacao.SelectedItem.ToString()));
 }
Example #28
0
 public RankingModule(IServiceProvider services)
 {
     _data    = services.GetRequiredService <DataService>();
     _ranking = services.GetRequiredService <RankingService>();
 }