Пример #1
0
        //[Route("CreateTraining/AddExercise/")]
        public async Task <IActionResult> PostExercise([FromBody] ExerciseViewModel exerciseViewModel)
        {
            if (ModelState.IsValid)
            {
                var TrainingNumber = await _exerciseService.AddExercise(exerciseViewModel);

                return(RedirectToAction("CreateTraining", new { TrainingNumber }));
            }

            return(View(exerciseViewModel));
        }
Пример #2
0
        public async Task <IActionResult> Put([FromBody] ExerciseModel model)
        {
            try
            {
                Console.WriteLine("Getting excercises");

                if (model == null)
                {
                    Console.WriteLine("bad request");
                    return(BadRequest("Введите данные"));
                }

                await _exerciseService.AddExercise(model.ToEntity());

                return(StatusCode(StatusCodes.Status201Created));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(StatusCode(StatusCodes.Status500InternalServerError, "Произошла ошибка, обратитесь в службу поддержки!"));
            }
        }
Пример #3
0
        public IActionResult AddExercise(NewExerciseVm model)
        {
            var id = _exerciseService.AddExercise(model);

            return(RedirectToAction("Index"));
        }