コード例 #1
0
        public void CreateOne()
        {
            Assert.AreEqual(0, _repo.GetAll().Count);

            Training training = new Training(1, DateTime.Now, new TimeSpan(0, 60, 0), new Team(), new Trainer());

            _repo.Add(training);

            Assert.AreEqual(1, _repo.GetAll().Count);
            Assert.AreEqual(training, _repo.GetTrainingById(training.Id));
        }
コード例 #2
0
        /// <summary>
        /// Command execution.
        /// </summary>
        public void Execute(object parameter)
        {
            try
            {
                var viewModel = parameter as HiitEditorViewModel;
                if (viewModel == null)
                {
                    return;
                }

                var training = trainingPlanner.NewTraining(viewModel.Name);

                foreach (var round in viewModel.Rounds)
                {
                    trainingPlanner.AddRound();

                    foreach (var exercise in round.Exercises)
                    {
                        trainingPlanner.AddExercise(round.RoundNumber - 1, exercise.Name, exercise.Duration);
                    }
                }

                trainingRepository.Add(training);
                hiitEditorView.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong on saving the activity.");
            }
        }
コード例 #3
0
        public ActionResult AddTraining(int id, string title)
        {
            User u = (User)Session["user"];

            repo.Add(u.Id, u.Name, id, title);
            return(RedirectToAction("../Home/Training"));
        }
コード例 #4
0
        public async Task <bool> Add(TrainingForAddDto trainingForAddDto, int userId)
        {
            var user = await _repoUser.GetUser(userId);

            var trainingToCreate = Training.Create(trainingForAddDto.Name.Trim(), trainingForAddDto.Date, user);

            foreach (var trainingExerciseDto in trainingForAddDto.Exercises)
            {
                var exercise = await _repoExercise.GetByName(trainingExerciseDto.Exercise.Name, user.Id);

                if (exercise == null)
                {
                    _repoExercise.Add(Exercise.Create(trainingExerciseDto.Exercise.Name, user));
                    await _repoExercise.SaveAll();

                    exercise = await _repoExercise.GetByName(trainingExerciseDto.Exercise.Name, user.Id);
                }
                var exerciseToCreate = TrainingExercise.Create(exercise, user);

                foreach (var set in trainingExerciseDto.Sets)
                {
                    var unit = await _repoUnit.GetByCode(set.Unit);

                    var setToCreate = TrainingExerciseSet.Create(set.Reps, set.Weight, unit, user);
                    exerciseToCreate.Sets.Add(setToCreate);
                }

                trainingToCreate.Exercises.Add(exerciseToCreate);
            }
            _repoTraining.Add(trainingToCreate);
            return(await _repoTraining.SaveAll());
        }
コード例 #5
0
ファイル: TrainingService.cs プロジェクト: sirhazman07/HRMS
        public Training Create(int trainingtypeId, decimal rateperhour)
        {
            var trainingType = _repoTrainingType.Get(trainingtypeId);
            var training     = new Training {
                TrainingTypeId = trainingtypeId, RatePerHour = rateperhour
            };

            _RepoTraining.Add(training);
            return(training);
        }
コード例 #6
0
ファイル: Service.cs プロジェクト: salac91/NEC_NS-Evidencija
        public void CreateTraining(Training training, Coach coach)
        {
            var dbCoach = _coachRepo.Get(c => c.COACH_INTERNAL_ID == coach.Coach_Internal_Id);

            var dbTraining = new TRAINING();

            dbTraining.TRAINING_INTERNAL_ID = training.Training_Internal_Id;
            dbTraining.DURATION             = training.Duration;
            dbTraining.NOTES     = training.Notes;
            dbTraining.STARTDATE = DateTime.ParseExact(training.StartDate, "yyyy-MM-dd",
                                                       System.Globalization.CultureInfo.InvariantCulture);
            dbTraining.TRAININGTHEME    = training.TrainingTheme;
            dbTraining.TRAININGTYPE     = training.TrainingType;
            dbTraining.TRAINING_QUALITY = training.TrainingQuality;
            dbTraining.RELATIONSHIP     = training.Relationship;
            dbTraining.COACH            = dbCoach;

            _trainingRepo.Add(dbTraining);

            _unitOfWork.Commit();
        }
コード例 #7
0
        public async Task <bool> Insert(Training training)
        {
            try
            {
                var status = await _repository.Add(training);

                return(status);
            }
            catch (OzoneException ex)
            {
                throw new OzoneException(ex.Message, ex.InnerException);
            }
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("Id,Description,BeginOf,EndOf,TeamId,TrainerId")] Training training)
        {
            if (ModelState.IsValid)
            {
                repository.Add(training);
                await repository.SaveAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamId"]    = new SelectList(team.GetAll(), "Id", "TeamType", training.TeamId);
            ViewData["TrainerId"] = new SelectList(trainer.GetAll(), "Id", "Surname", training.TrainerId);
            return(View(training));
        }
コード例 #9
0
        public async Task <int> Handle(CreateTrainingCommand request, CancellationToken cancellationToken)
        {
            var training = new Training
            {
                Description    = request.Description,
                Location       = request.Location,
                TrainingPeriod = new DateTimeRange(request.Start, request.End),
            };

            await _repo.Add(training);

            return(training.Id);
        }
コード例 #10
0
        public int AddTraining(TrainingDto trainingDto)
        {
            Training training = new Training()
            {
                Id        = 0,
                Name      = trainingDto.Name,
                StartDate = trainingDto.StartDate,
                EndDate   = trainingDto.EndDate
            };

            _trainingRepository.Add(training);

            return((int)(trainingDto.EndDate - trainingDto.StartDate).TotalDays);
        }
コード例 #11
0
        public async Task <IActionResult> PostTraining([FromBody] Training training)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            if (await _repo.Add(training))
            {
                return(Ok(CreatedAtAction("GetTraining", new { id = training.Id }, training)));
            }

            return(BadRequest("Could not add training"));
        }
コード例 #12
0
        public bool CreateTraining(Training training)
        {
            bool isSuccess = true;

            try
            {
                trainingRepository.Add(training);
                this.SaveRecord();
                ServiceUtil <Training> .WriteActionLog(training.Id, ENUMOperation.CREATE, training);
            }
            catch (Exception ex)
            {
                isSuccess = false;
                logger.Error("Error in creating Training", ex);
            }
            return(isSuccess);
        }
コード例 #13
0
        public async Task <IActionResult> createTraining([FromBody] SaveTrainingResource trainingResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Training training = mapper.Map <SaveTrainingResource, Training>(trainingResource);
            DateTime now      = DateTime.Now;

            training.InsertDate = now;
            training.LastUpdate = now;
            trainingRepository.Add(training);
            await unitOfWork.CompleteAsync();

            Training trainingToMap = await trainingRepository.GetOne(training.Id);

            var response = mapper.Map <Training, TrainingResource>(trainingToMap);

            return(Ok(response));
        }
コード例 #14
0
 public TblTrainingList PostTraining(TblTrainingList item)
 {
     return(repository.Add(item));
 }
コード例 #15
0
 public IActionResult Post([FromBody] Training item)
 {
     _repository.Add(item);
     return(Ok("New Training  Added"));
 }
コード例 #16
0
        public Training Add(Training entity)
        {
            var result = trainingRepository.Add(entity);

            return(result);
        }
コード例 #17
0
 public IActionResult Post([FromBody] Training item)
 {
     _repository.Add(item);
     return(Ok("Record Added.."));
 }
コード例 #18
0
 public void Add(Training training)
 {
     trainingRepository.Add(training);
 }
コード例 #19
0
 /// <summary>
 /// Saves the last training.
 /// </summary>
 public void SaveTraining()
 {
     trainingRepository.Add(training);
 }
コード例 #20
0
        public void AddTraining(Training training)
        {
            var trainingDb = ToTrainingDb(training);

            repository.Add(trainingDb);
        }