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)); }
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")); } }