Exemple #1
0
        private async void BtnSave_Clicked(object sender, EventArgs e)
        {
            //_Routine.RoutineExercises = new HashSet<int>(_ViewModel.Exercises.Where(ex => ex.IsSelected)
            //    .Select(ex => ex.Exercise.Id).ToArray());

            //Was mache ich hier? Das verstehe ich momentan noch nicht:
            //Speichere ich über die Routine separat von den RoutineExercises?
            //Und die RoutineExercise über ihr eigenes Repository? Und wie mache ich das beim laden der Routine?
            //Oder speichere ich alles über die Routine und die Unit of Work speichert dann alles selber?

            _Routine.RoutineExercises = new List <RoutineExercise>();
            var exerciseIds = _ViewModel.Exercises.Where(ex => ex.IsSelected).Select(ex => ex.Exercise.Id);

            //ToDo: Not the duty of the View
            foreach (var id in exerciseIds)
            {
                _Routine.RoutineExercises.Add(new RoutineExercise
                {
                    Id         = TrainingContext.GetRoutineExerciseId(), //IdHelper.GetRoutineExerciseId(_Uow.Routines);
                    IdExercise = id,
                    IdRoutine  = _Routine.Id
                });
            }
            RoutineRepository.Instance.Add(_Routine); //_Uow.Routines.Add(_Routine);

            await this.Navigation.PopModalAsync();
        }
Exemple #2
0
        public TrainingService()
        {
            var options = new DbContextOptionsBuilder <TrainingContext>().UseSqlite("Data Source=training.db").Options;

            _context    = new TrainingContext(options);
            _repository = new Repository <Training>(_context);
        }
        private async void BtnSave_Clicked(object sender, EventArgs e)
        {
            Routine routine;
            RoutineEditViewModel vm = (RoutineEditViewModel)BindingContext;

            routine = vm.Routine;

            if (routine.Title != entryTitle.Text)
            {
                routine.Title = entryTitle.Text;
            }

            routine.Description = entryDescription.Text;

            var choosenRoutineExercises = new List <RoutineExercise>();
            var exerciseIds             = vm.Exercises.Where(ex => ex.IsSelected).Select(ex => ex.Exercise.Id);

            //Add the selected exercises to the routine
            foreach (var id in exerciseIds)
            {
                choosenRoutineExercises.Add(new RoutineExercise          //_Uow.Routines.Add(...)
                {
                    Id         = TrainingContext.GetRoutineExerciseId(), //IdHelper.GetRoutineExerciseId(_Uow.Routines);
                    IdExercise = id,
                    IdRoutine  = routine.Id
                });
            }

            //This causes a PropertyChanged event on the routine which leads to an update of the Exercises
            //which is the collection that is represented in the ListView
            routine.RoutineExercises = choosenRoutineExercises;

            await this.Navigation.PopModalAsync();
        }
Exemple #4
0
 public EmployeeDBRepository(TrainingContext context, ILogger <IRepository <EmployeeDTO> > logger)
 {
     this.context = context;
     this.logger  = logger;
     employeeDTOs = context.Employees;
     positionDTOs = context.Positions;
 }
Exemple #5
0
 private void InitializeDatabase(TrainingContext trainingContext)
 {
     if (trainingContext.Database.EnsureCreated())
     {
         trainingContext.Database.Migrate();
     }
 }
Exemple #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TrainingContext trainingContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors("AllowAllDEV");

            InitializeDatabase(trainingContext);

            app.UseSwagger();

            app.UseGraphiQLServer();

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "GraphQL API V1");
                c.RoutePrefix = string.Empty;
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
        private void Button_second_Click(object sender, RoutedEventArgs e)
        {
            this.Button_first.Background = new SolidColorBrush(Color.FromRgb(67, 67, 67));
            this.Button_first.Foreground = new SolidColorBrush(Color.FromRgb(222, 222, 222));

            this.Button_second.Background = new SolidColorBrush(Color.FromRgb(222, 222, 222));
            this.Button_second.Foreground = new SolidColorBrush(Color.FromRgb(254, 95, 27));

            this.Button_third.Background = new SolidColorBrush(Color.FromRgb(67, 67, 67));
            this.Button_third.Foreground = new SolidColorBrush(Color.FromRgb(222, 222, 222));

            this.Button_four.Background = new SolidColorBrush(Color.FromRgb(67, 67, 67));
            this.Button_four.Foreground = new SolidColorBrush(Color.FromRgb(222, 222, 222));

            var panel = new StackPanel();

            using (TrainingContext db = new TrainingContext())
            {
                db.Trainings.Load();
                var list = db.Trainings.Local.ToBindingList();
                foreach (var item in list)
                {
                    if (item.Groupe == 2 && item.ID_type == 0)
                    {
                        var a = new TrainBlock(item, user);
                        panel.Children.Add(a);
                    }
                }
            }
            this.List_train.Content = panel;
        }
Exemple #8
0
        public IActionResult Index()
        {
            var context = new TrainingContext();

            var student = new Student()
            {
                Name           = "Jalaluddin",
                BirthDate      = DateTime.Now,
                StudentCourses = new List <StudentCourse>()
            };

            var course = new Course()
            {
                Name   = "Laravel",
                Price  = 20000,
                Topics = new List <CourseTopic>()
            };

            course.Topics.Add(new CourseTopic()
            {
                Name        = "Intro",
                Description = "Getting started"
            });


            student.StudentCourses.Add(new StudentCourse()
            {
                Course = course
            });

            context.Students.Add(student);
            context.SaveChanges();

            return(View());
        }
Exemple #9
0
 public Trainer(IConfiguration config, TelemetryConfiguration telemetryConfig, TrainingContext trainingContext)
 {
     _config                   = config;
     _trainingContext          = trainingContext;
     _telemetryClient          = new TelemetryClient(telemetryConfig);
     _dbConnectionString       = _config.GetConnectionString("PlaceboDatabase");
     _recognizerServiceBaseUrl = _config["RecognizerServiceBaseUrl"];
 }
        protected override void define()
        {
            using (var ctx = new TrainingContext())
            {
                #region DATASET

                var data = ctx.Database.Connection.Query("select * from vw_AllTrainings")
                           .Where(e => e.DateExpiresAt < DateTimeOffset.Now.AddDays(15))
                           .Select(e => new
                {
                    e.Name,
                    e.LastName,
                    e.MotherLastName,
                    e.ClockNumber,
                    e.JobPosition,
                    e.Area,
                    e.Shift,
                    e.Supervisor,
                    e.Score,
                    e.ScoreNotes,
                    //e.TrainingCreatedAt,
                    e.DateProgrammed,
                    e.DateStart,
                    e.DateEnd,
                    e.DateCertification,
                    e.DateExpiresAt,
                    e.Trainer,
                    e.InternalExternal,
                    e.TrainingNotes,
                    //e.QuickTraining,
                    e.DurationInHours,
                    e.Certification,
                    e.ILUO,
                    e.AppliesToDC3,
                    e.LifecycleInMonths,
                    IsExpired = e.DateExpiresAt < DateTimeOffset.Now
                })
                           .ToList();

                #endregion

                #region DOCUMENT
                InitWorkBook("About to Expire");
                #endregion

                CreateWorkSheet("About to Expire");
                InsertHeader("About to Expire");

                #region Detail
                CurrentCell().LoadFromCollection(data);
                ws.Cells[3, 1, CurrentRow() - 1, 23].AutoFilter = true;
                #endregion

                #region Layout
                ConfigLayout();
                #endregion
            }
        }
Exemple #11
0
        public TrainingControllerTest()
        {
            var options = new DbContextOptionsBuilder <TrainingContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            context      = new TrainingContext(options);
            myController = new TrainingsController(context);
        }
 public override void AdapterOut(params MRORequest[] entities)
 {
     using (var trainingContext = new TrainingContext())
     {
         foreach (var item in entities)
         {
             item.Employee = trainingContext.Employees.FirstOrDefault(e => e.EmployeeKey == item.EmployeeKey);
         }
     }
 }
Exemple #13
0
        public static TrainingContext CreateTrainingContext(List <LayerSpec> layers, Mat trainingData, Vec outputData)
        {
            var ptr = QMCreateTrainingContext(Structify(layers), layers.Count, trainingData.ToRowWiseArray(), outputData.ToArray(),
                                              trainingData.RowCount, trainingData.ColumnCount);
            var tc = new TrainingContext(ptr, outputData.Count);

            tc.InputCount  = trainingData.RowCount;
            tc.WeightCount = GetWeightCount(layers, trainingData.RowCount);
            return(tc);
        }
Exemple #14
0
 public ProjectDBRepository(TrainingContext context, ILogger <IRepository <ProjectDTO> > logger)
 {
     this.logger  = logger;
     this.context = context;
     projectDTOs  = context.Projects;
     taskDTOs     = context.Tasks;
     employeeDTOs = context.Employees;
     statusDTOs   = context.Statuses;
     positionDTOs = context.Positions;
 }
Exemple #15
0
        static void CreateData(TrainingContext db)
        {
            Teacher t1 = new Teacher {
                Name = "Miss Anderson"
            };
            Teacher t2 = new Teacher {
                Name = "Miss Bingham"
            };

            Classroom r1 = new Classroom {
                Number = "R101"
            };
            Classroom r2 = new Classroom {
                Number = "R202"
            };

            Course c1 = new Course {
                Title = "Introduction to EF Core", Author = t1, Editor = t2
            };
            Course c2 = new Course {
                Title = "Basic Car Maintenance", Author = t2, Editor = t1
            };

            Student s1 = new Student {
                Name = "Jenny Jones", Classroom = r1
            };
            Student s2 = new Student {
                Name = "Kenny Kent", Classroom = r1
            };
            Student s3 = new Student {
                Name = "Lucy Locket", Classroom = r1
            };
            Student s4 = new Student {
                Name = "Micky Most", Classroom = r2
            };
            Student s5 = new Student {
                Name = "Nelly Norton", Classroom = r2
            };
            Student s6 = new Student {
                Name = "Ozzy Osborne", Classroom = r2
            };


            c1.Students = new Student[] { s1, s2, s3, s4 };
            c2.Students = new Student[] { s3, s4, s5, s6 };

            db.Add(c1);
            db.Add(c2);

            db.SaveChanges();
        }
Exemple #16
0
        public static WeightEvalInfo EvaluateWeights(this TrainingContext trainingContext, Vec weights)
        {
            Debug.Assert(weights.Count == trainingContext.WeightCount);
            var    weightArray = weights.ToArray();
            double error;

            double[] grad   = new double[weightArray.Length];
            double[] output = new double[trainingContext.NumOutputs];
            QMEvaluateWeights(trainingContext.Ptr, weightArray, weightArray.Length, output, out error, grad);
            return(new WeightEvalInfo
            {
                Output = new DenseVector(output),
                Error = error,
                Gradient = new DenseVector(grad)
            });
        }
Exemple #17
0
        static void Main()
        {
            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json")
                                    .Build();

            var options = new DbContextOptionsBuilder <TrainingContext>()
                          .UseSqlServer(config.GetConnectionString("TrainingDB"))
                          .Options;

            using var db = new TrainingContext(options);

            db.Database.EnsureDeleted();
            db.Database.EnsureCreated();

            CreateData(db);
        }
Exemple #18
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            int id_train;

            if (Intensity_num != 0 && type_train != 0 && list_ex_id.Count != 0 && this.new_name.Text != "")
            {
                using (TrainingContext db = new TrainingContext())
                {
                    Training new_train = new Training {
                        Name_training = this.new_name.Text, Description = this.new_Disc.Text, Groupe = type_train, ID_training = 1, ID_type = user.ID_user, Img = "/Training/user_training.png", Intensity = Intensity_num, Time = time_ex_all
                    };
                    db.Trainings.Add(new_train);
                    db.SaveChanges();
                }

                using (TrainingContext db = new TrainingContext())
                {
                    db.Trainings.Load();
                    var list = db.Trainings.Local.ToBindingList();
                    id_train = list.Count;
                }

                using (ConnectionContext db = new ConnectionContext())
                {
                    foreach (var item in list_ex_id)
                    {
                        var new_con = new Connection {
                            ID_note = 1, ID_ex = item, ID_training = id_train
                        };
                        db.Connections.Add(new_con);
                    }
                    db.SaveChanges();
                }

                var win_user_train = new MainTrainWin(user);
                win_user_train.Show();
                win_c.Close();
            }
            else
            {
                var win_er = new ERRORWin();
                win_er.ChooseError("ERRORDataEntry");
                win_er.Show();
            }
        }
Exemple #19
0
        protected override void define()
        {
            using (var ctx = new TrainingContext())
            {
                #region DATASET

                var entities = ctx.Database.Connection.Query("select * from vw_Headcount where name is not null")
                               .Select(e => new
                {
                    e.Shift,
                    e.Area,
                    e.JobPosition,
                    e.Supervisor,
                    e.ClockNumber,
                    e.Name,
                    e.LastName,
                    e.MotherLastName,
                    e.CURP,
                    e.HireDate
                })
                               .ToList();

                #endregion

                #region DOCUMENT
                InitWorkBook("Headcount");
                #endregion

                CreateWorkSheet("Headcount");
                InsertHeader("Headcount");

                #region Detail
                CurrentCell().LoadFromCollection(entities);
                ws.Cells[3, 1, CurrentRow() - 1, 10].AutoFilter = true;
                #endregion

                #region Layout
                ConfigLayout();
                #endregion
            }
        }
        public All_train(User us)
        {
            user = us;
            InitializeComponent();
            var panel = new StackPanel();

            using (TrainingContext db = new TrainingContext())
            {
                db.Trainings.Load();
                var list = db.Trainings.Local.ToBindingList();
                foreach (var item in list)
                {
                    if (item.ID_type == 0)
                    {
                        var a = new TrainBlock(item, us);
                        panel.Children.Add(a);
                    }
                }
                this.List_train.Content = panel;
            }
        }
        public InspectionQuery(TrainingContext db)
        {
            Field <ListGraphType <InspectionType> >(
                "Inspections",
                resolve: context =>
            {
                var inspections = db.Inspections;
                return(inspections);
            });

            Field <InspectionType>(
                "Contract",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "Id", Description = "The Id of the Inspection."
            }),
                resolve: context =>
            {
                var id         = context.GetArgument <Guid>("Id");
                var inspection = db.Inspections;
                return(inspection);
            });
        }
        public OperationQuery(TrainingContext db)
        {
            Field <ListGraphType <OperationType> >(
                "Operations",
                resolve: context =>
            {
                var operations = db.Operations.Include(x => x.Contract).Include(x => x.Inspections);
                return(operations);
            });

            Field <OperationType>(
                "Operation",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "Id", Description = "The Id of the Operation."
            }),
                resolve: context =>
            {
                var id        = context.GetArgument <Guid>("Id");
                var operation = db.Operations.Include(x => x.Inspections).FirstOrDefault(x => x.Id == id);
                return(operation);
            });
        }
Exemple #23
0
        static void Main(string[] args)
        {
            var   ctx   = new TrainingContext();
            Batch batch = new Batch()
            {
                BatchID    = 1,
                BatchName  = "Jan15-CS",
                BatchOwner = "Sharan"
            };
            Trainee trainee = new Trainee()
            {
                TraineeID     = 101,
                TraineeName   = "John",
                EmailID       = "*****@*****.**",
                DateOfJoining = Convert.ToDateTime("01/01/2015"),
                Batch         = batch
            };

            ctx.Trainees.Add(trainee);
            ctx.SaveChanges();
            Console.WriteLine("Done");
            Console.ReadLine();
        }
Exemple #24
0
        public ContractQuery(TrainingContext db)
        {
            Field <ListGraphType <ContractType> >(
                "Contracts",
                resolve: context =>
            {
                var contracts = db.Contracts.Include(x => x.Operations).ThenInclude(x => x.Inspections);
                return(contracts);
            });

            Field <ContractType>(
                "Contract",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "Id", Description = "The Id of the Contract."
            }),
                resolve: context =>
            {
                var id       = context.GetArgument <Guid>("Id");
                var contract = db.Contracts.Include(x => x.Operations).ThenInclude(x => x.Inspections).FirstOrDefault(x => x.Id == id);
                return(contract);
            });
        }
Exemple #25
0
 public RepositorySession(TrainingContext TrainingContext)
 {
     this.TrainingContext = TrainingContext;
 }
 public EventController()
 {
     TrainingContext = new TrainingContext();
     RepoEvent       = new RepositoryEvent(TrainingContext);
 }
Exemple #27
0
 public TrainingsRepository(TrainingContext context)
 {
     _context = context;
 }
 public TrainingController()
 {
     context = new TrainingContext();
 }
Exemple #29
0
 public RunningRepository(TrainingContext context)
 {
     this.context = context;
 }
 public TrainingService()
 {
     _trainingContext = new TrainingContext();
 }