Exemple #1
0
        public JsonResult Create(ErrorDto errorDto)
        {
            ErrorDto savedErrorDto;

            using (ITransaction transaction = Session.BeginTransaction())
            {
                Error error = Error.Create(errorDto);
                ErrorManager.Save(error);

                savedErrorDto = ErrorDto.Create(error);

                transaction.Commit();
            }

            return(Json(savedErrorDto));
        }
Exemple #2
0
        public ActionResult <ErrorDTO> Create(ErrorDTO error)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }

                _errorManager.Save(error);

                return(Ok());
            }
            catch (LevelNotFoundException)
            {
                return(BadRequest("Level does not exist"));
            }
            catch (CategoryNotFoundException)
            {
                return(BadRequest("Category does not exist"));
            }
        }