Beispiel #1
0
        public Exercicio Create(CreateExercicioCommand command)
        {
            var exercicio = new Exercicio(command.DsExercicio, command.TreinoId);

            exercicio.CreateExercicio();
            _repository.Create(exercicio);

            if (Commit())
            {
                return(exercicio);
            }

            return(null);
        }
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);
        }