//Authorize]
        public Result <IList <Goals> > GetAll(int plannerId)
        {
            var          result       = new Result <IList <Goals> >();
            GoalsService GoalsService = new GoalsService();

            result.Value     = GoalsService.GetAll(plannerId);
            result.IsSuccess = true;
            return(result);
        }
        public Result <Goals> Get(int id, int plannerId)
        {
            var          result       = new Result <Goals>();
            GoalsService GoalsService = new GoalsService();

            result.Value     = GoalsService.GetById(id, plannerId);
            result.IsSuccess = true;
            return(result);
        }
Exemple #3
0
        public Goals GetGoals(User user, DateTime date)
        {
            var goalsService = new GoalsService()
            {
                User = user
            };

            return(goalsService.Goals.Where(g => date >= g.GoalStartDate && date <= g.GoalEndDate).FirstOrDefault());
        }
Exemple #4
0
        public void AddGoal(User user, Goals goals)
        {
            var goalsService = new GoalsService()
            {
                User = user
            };

            goalsService.AddGoals(goals);
        }
Exemple #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOptions();
            services.Configure <NlpConfiguration>(Configuration.GetSection(nameof(NlpConfiguration)));
            services.Configure <TokenConfiguration>(Configuration.GetSection(nameof(TokenConfiguration)));

            services.AddDbContext <ChatContext>
                (options => options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")), ServiceLifetime.Singleton);

            // Background services
            services.AddTransient <IGoalsService, GoalsService>();

            services.AddSingleton <IMockTrainingService, MockTrainingService>(sp =>
            {
                using (var scope = sp.CreateScope())
                {
                    var context    = scope.ServiceProvider.GetService <ChatContext>();
                    var logger     = scope.ServiceProvider.GetService <ILogger <GoalsService> >();
                    var goals      = new GoalsService(context, logger);
                    var config     = Configuration.GetSection(nameof(TrainingMockConfiguration)).Get <TrainingMockConfiguration>();
                    var hub        = scope.ServiceProvider.GetService <IHubContext <TrainingHub> >();
                    var mockLogger = scope.ServiceProvider.GetService <ILogger <MockTrainingService> >();
                    return(new MockTrainingService(goals, config, hub, mockLogger));
                }
            });

            // Gerneral Services
            services.AddScoped <IAuthenticationService, JWTAuthenticationService>();
            services.AddScoped <IGuideService, JsonGuideService>();

            // NLP
            services.AddScoped <INlpService, MnemonicReaderService>();
            services.AddScoped <IBotService, MarleyService>();

            // DAL
            services.AddScoped <ITrainingService, TrainingService>();
            services.AddScoped <ISessionsService, SessionService>();

            services.AddMvc();
            ConfigureAuthentication(services);
            services.AddCors(o => o.AddPolicy("CorsPolicy", builder =>
            {
                builder
                .AllowAnyMethod()
                .AllowAnyHeader()
                .WithOrigins("http://localhost:4200");
            }));
            // SignalR and CORS
            services.AddSignalR();
        }
        public Result Delete(Goals Goals)
        {
            var result = new Result();

            try
            {
                GoalsService GoalsService = new GoalsService();
                GoalsService.Delete(Goals);
                result.IsSuccess = true;
            }
            catch (Exception exception)
            {
                result.IsSuccess     = false;
                result.ExceptionInfo = exception;
            }
            return(result);
        }
Exemple #7
0
        // récupère le nombre de goals pour une équipe à un quarter
        public int getGoals(JoueursModele joueur, List <MatchsModele> lMatchs, QuartersModele quarter)
        {
            List <GoalsModele> lGoals = new GoalsService().ListAll();
            int count = 0;

            foreach (GoalsModele goal in lGoals)
            {
                if (goal.joueurId == joueur.joueurId)
                {
                    foreach (MatchsModele match in lMatchs)
                    {
                        if (match.matchId == goal.matchId && match.matchDate <= quarter.dateFin && match.matchDate >= quarter.dateDebut)
                        {
                            count++;
                        }
                    }
                }
            }
            return(count);
        }
Exemple #8
0
 public GoalController(GoalsService goalsService)
 {
     _goalsService = goalsService;
 }
Exemple #9
0
 public GoalControllerTests()
 {
     repository     = new MockRepository();
     goalsService   = new GoalsService(repository);
     goalController = new GoalController(goalsService);
 }
Exemple #10
0
 public TodosController(TodosService tdService, GoalsService goalsService)
 {
     _tdService    = tdService;
     _goalsService = goalsService;
 }
Exemple #11
0
 public GoalsController(GoalsService service)
 {
     _service = service;
 }
Exemple #12
0
        private void b_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkFeuilleExiste())
                {
                    if (checkFull((DataView)dg_GoalsEq1.DataSource) && checkFull((DataView)dg_GoalsEq2.DataSource) &&
                        checkFull((DataView)dg_CartJauEq1.DataSource) && checkFull((DataView)dg_CartJaunEq2.DataSource) &&
                        checkFull((DataView)dg_CartRougEq1.DataSource) && checkFull((DataView)dg_CartRougEq2.DataSource))

                    {
                        if (checkMin((DataView)dg_GoalsEq1.DataSource) && checkMin((DataView)dg_GoalsEq2.DataSource) &&
                            checkMin((DataView)dg_CartJauEq1.DataSource) && checkMin((DataView)dg_CartJaunEq2.DataSource) &&
                            checkMin((DataView)dg_CartRougEq1.DataSource) && checkMin((DataView)dg_CartRougEq2.DataSource))
                        {
                            if (checkCartesRougesA((DataView)dg_GoalsEq1.DataSource) && checkCartesRougesB((DataView)dg_GoalsEq2.DataSource))
                            {
                                if (checkCartesRougesA((DataView)dg_CartJauEq1.DataSource) && checkCartesRougesB((DataView)dg_CartJaunEq2.DataSource))
                                {
                                    if (checkPasDoubleCarteRouge((DataView)dg_CartRougEq1.DataSource) && checkPasDoubleCarteRouge((DataView)dg_CartRougEq2.DataSource))
                                    {
                                        DialogResult dialogResult = MessageBox.Show("Pour des raisons de sécurité, on ne peut encoder qu'une seule fois les cartes, une fois sorti de la fenêtre vous ne pourrez plus les modifier, êtes vous sûrs que tout est bon ?", "Confirm", MessageBoxButtons.OKCancel);
                                        if (dialogResult == DialogResult.OK)
                                        {
                                            GoalsService gs = new GoalsService();
                                            gs.SaveAll((DataView)dg_GoalsEq1.DataSource, matchId, equipeAId);
                                            gs.SaveAll((DataView)dg_GoalsEq2.DataSource, matchId, equipeBId);

                                            CartesJaunesService cjs = new CartesJaunesService();
                                            cjs.SaveAll((DataView)dg_CartJauEq1.DataSource, matchId, equipeAId);
                                            cjs.SaveAll((DataView)dg_CartJaunEq2.DataSource, matchId, equipeBId);

                                            CartesRougesService crs = new CartesRougesService();
                                            crs.SaveAll((DataView)dg_CartRougEq1.DataSource, matchId, equipeAId);
                                            crs.SaveAll((DataView)dg_CartRougEq2.DataSource, matchId, equipeBId);

                                            MatchsService ms = new MatchsService();
                                            ms.UpdateIsPlayed(matchId);

                                            this.Close();
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Un ou des joueurs ont plusieurs cartes rouges");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Un ou des joueurs ont reçu des cartons rouges avant de recevoir un carton jaune");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Un ou des joueurs ont reçu des cartons rouges avant de marquer");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Tous les champs minutes doivent être compris entre 0 et 120");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Tous les champs doivent être soit remplis soit vides");
                    }
                }
                else
                {
                    MessageBox.Show("Pour enregistrer des résultats il faut que les feuilles de matchs soient créées");
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #13
0
 public GoalsServiceTests()
 {
     _repository   = new MockRepository();
     _goalsService = new GoalsService(_repository);
 }