Exemplo n.º 1
0
        public HttpResponseMessage Post(WorkoutViewModel workoutViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var workoutEntity = new Workout();
                    workoutEntity = MapToEntity(workoutViewModel, workoutEntity);

                    _workoutService.CreateWorkout(workoutEntity);

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Invalid Model"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }