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)); }
/// <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."); } }
public ActionResult AddTraining(int id, string title) { User u = (User)Session["user"]; repo.Add(u.Id, u.Name, id, title); return(RedirectToAction("../Home/Training")); }
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()); }
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); }
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(); }
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); } }
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)); }
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); }
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); }
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")); }
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); }
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)); }
public TblTrainingList PostTraining(TblTrainingList item) { return(repository.Add(item)); }
public IActionResult Post([FromBody] Training item) { _repository.Add(item); return(Ok("New Training Added")); }
public Training Add(Training entity) { var result = trainingRepository.Add(entity); return(result); }
public IActionResult Post([FromBody] Training item) { _repository.Add(item); return(Ok("Record Added..")); }
public void Add(Training training) { trainingRepository.Add(training); }
/// <summary> /// Saves the last training. /// </summary> public void SaveTraining() { trainingRepository.Add(training); }
public void AddTraining(Training training) { var trainingDb = ToTrainingDb(training); repository.Add(trainingDb); }