Beispiel #1
0
        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);
        }
Beispiel #2
0
        public Task <HttpResponseMessage> Post([FromBody] dynamic body)
        {
            var response = new HttpResponseMessage();

            try
            {
                //_treinoController.Post(body);

                var exercicios = _service.GetUsuario((string)body.email, (string)body.treino);
                try
                {
                    var exer = _service.GetByExercicio((string)body.email, (string)body.exercicio);

                    if (exer.DsExercicio.Equals((string)body.exercicio))
                    {
                    }
                    else
                    {
                        var command = new CreateExercicioCommand(
                            dsExercicio: (string)body.exercicio,
                            treinoId: exer.TreinoId
                            );

                        var exercicio = _service.Create(command);
                    }
                }
                catch
                {
                    var command = new CreateExercicioCommand(
                        dsExercicio: (string)body.exercicio,
                        treinoId: exercicios.TreinoId
                        );

                    var exercicio = _service.Create(command);
                }

                //return CreateResponse(HttpStatusCode.Created, exercicio);
            }
            catch
            {
                response = Request.CreateResponse(HttpStatusCode.BadRequest, "Exercicio não foi criado!");
            }
            var tsc = new TaskCompletionSource <HttpResponseMessage>();

            tsc.SetResult(response);
            return(tsc.Task);
        }