public Task <HttpResponseMessage> Post([FromBody] dynamic body) { var response = new HttpResponseMessage(); try { _exercicioController.Post(body); //var evolucaoTreinos = _service.GetUsuario((string)body.email); var evolucaoTreinos = _serviceExercicio.GetByExercicio((string)body.email, (string)body.exercicio); var command = new CreateEvolucaoTreinoCommand( repeticao: (int)body.repeticao, carga: (int)body.carga, //aumentoTreino: (DateTime)body.aumento, exercicioId: evolucaoTreinos.ExercicioId ); var evolucao = _service.Create(command); return(CreateResponse(HttpStatusCode.Created, evolucao)); } catch { response = Request.CreateResponse(HttpStatusCode.BadRequest, "O Evolucao do treino não foi criado!"); } var tsc = new TaskCompletionSource <HttpResponseMessage>(); tsc.SetResult(response); return(tsc.Task); }
public EvolucaoTreino Create(CreateEvolucaoTreinoCommand command) { var evolucaoTreino = new EvolucaoTreino(command.Repeticao, command.Carga, command.ExercicioId); evolucaoTreino.CreateEvolucaoTreino(); _repository.Create(evolucaoTreino); if (Commit()) { return evolucaoTreino; } return null; }