Ejemplo n.º 1
0
        public HttpResponseMessage Post(LevelGroupModel levelGroup)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(
                           HttpStatusCode.BadRequest,
                           new HttpError(ModelState.FirstError())));
            }

            try
            {
                _service.InsertLevelGroup(Mapper.Map <LevelGroup>(levelGroup));
                return(Request.CreateResponse());
            }
            catch (Exception ex)
            {
                _logger.Error("Error when inserting new Level Group", ex);
                return(Request.CreateErrorResponse(
                           HttpStatusCode.InternalServerError,
                           new HttpError(_resourceManager.GetString(ExceptionResources.GeneralException))));
            }
        }