// POST: api/RequestAuthToken public HttpResponseMessage Post(Models.TokenCreationRequestModel tokenCreationRequest) { try { var errorModel = new Models.ErrorModel { InnerException = "string", Message = "string", Code = 0 }; var tokenCreationResponse = new Models.TokenCreationResponseModel { Token = "string", Error = errorModel }; return(Request.CreateResponse(HttpStatusCode.OK, tokenCreationResponse)); } catch { var errorModel = new Models.ErrorModel { InnerException = "Unexpected condition encountered", Message = "Oops, this wasn't supposed to happen !!!", Code = 50001 }; return(Request.CreateResponse(HttpStatusCode.InternalServerError, errorModel)); } }
// GET: api/Health public HttpResponseMessage Get() { try { var errorModel = new Models.ErrorModel { InnerException = "string", Message = "string", Code = 0 }; var healthModel = new Models.HealthModel { Error = errorModel, message = "string", Health = nameof(Models.HealthModel.health.green) }; return(Request.CreateResponse(HttpStatusCode.OK, healthModel)); } catch { var errorModel = new Models.ErrorModel { InnerException = "Unexpected condition encountered", Message = "Oops, this wasn't supposed to happen !!!", Code = 50001 }; return(Request.CreateResponse(HttpStatusCode.InternalServerError, errorModel)); } }
// Takes in errorCode and returns custom Error page public ActionResult Error(int errorCode = 0) { // instantiates new error object embedded with custom error code var error = new Models.ErrorModel { MErrorCode = errorCode }; return(View("Error", error)); }
public ActionResult <Models.TbCurso> ConsultarCurso(int id) { try { return(db.ConsultarCurso(id)); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <List <Models.SalaVestibularResponse1> > Consultar() { try { return(business.Consultar()); } catch (System.ArgumentException ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <Models.TbSalaVestibular> BuscarPorID(int id) { try { return(business.BuscarPorID(id)); } catch (System.ArgumentException ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <Models.TbSala> BuscarPorNome(string nome) { try { return(business.BuscarPorNome(nome)); } catch (System.ArgumentException ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult AlterarSenha(Models.TbLogin login) { try { business.AlterarSenha(login); return(Ok()); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <List <Models.ProfessorResponse> > ConsultarNome(string nome) { try { List <Models.ProfessorResponse> professor = business.ConsultarPorNome(nome); return(professor); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <List <Models.ProfessorResponse> > ListarTodos() { try { List <Models.ProfessorResponse> professores = business.ListarTodos(); return(professores); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult Remover(int idProfessor, int idLogin) { try { business.Remover(idProfessor, idLogin); return(Ok()); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult Alterar(Models.ProfessorRequest professor) { try { business.Alterar(professor); return(Ok()); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <List <Models.TbCurso> > ConsultarPorSigla(string sigla) { try{ List <Models.TbCurso> consulta = business.ConsultarPorSigla(sigla); return(consulta); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <List <Models.TbCurso> > ListarTodos() { try { List <Models.TbCurso> cursos = db.ListarTodos(); return(cursos); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <List <Models.SalaVestibularResponse> > ListarTudo() { try { List <Models.SalaVestibularResponse> consulta = business.ListarTudo(); return(consulta); } catch (System.Exception ex) { Models.ErrorModel error = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, error)); } }
public ActionResult Remover(int id) { try { business.Deletar(id); return(Ok()); } catch (System.ArgumentException ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <List <Models.TbCurso> > ConsultarPorNome(string NmCurso) { try { List <Models.TbCurso> cursos = db.ConsultarPorNome(NmCurso); return(cursos); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <Models.TbDisciplina> Insert(Models.TbDisciplina livro) { try { business.Inserir(livro); return(livro); } catch (System.ArgumentException ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult Alterar(Models.TbSalaVestibular modelo) { try { business.Alterar(modelo); return(Ok()); } catch (System.ArgumentException ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <Models.TbCurso> AlterarCurso(Models.TbCurso curso) { try { business.Alterar(curso); return(Ok()); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult <Models.TbSala> Inserir(Models.TbSala modelo) { try { business.Inserir(modelo); return(modelo); } catch (System.ArgumentException ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
//private static readonly ILog log = // log4net.LogManager.GetLogger(System.Reflection.MethodBase // .GetCurrentMethod().DeclaringType); public ActionResult Error(int statusCode, Exception exception) { Response.StatusCode = statusCode; var error = new Models.ErrorModel { StatusCode = statusCode.ToString(), Description = HttpWorkerRequest.GetStatusDescription(statusCode), Message = exception.Message, DateTime = DateTime.Now }; return(View(error)); }
public ActionResult <Models.TbCurso> RemoverCurso(int id) { try { business.Remover(id); return(Ok()); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult Error(int statusCode, Exception ex) { Response.StatusCode = statusCode; Models.ErrorModel e; if (Session["_ERROR_"] != null && (Session["_ERROR_"].GetType() == typeof(Exception) || Session["_ERROR_"].GetType() == typeof(HttpException))) { e = new Models.ErrorModel((Exception)Session["_ERROR_"]); } else { e = new Models.ErrorModel(ex); } return(View("ErrorView", e)); }
public ActionResult <int> Inserir(Models.TbCurso curso) { try { db.Inserir(curso); int id = curso.IdCurso; return(id); } catch (System.Exception ex) { Models.ErrorModel erro = new Models.ErrorModel(500, ex.Message); return(StatusCode(500, erro)); } }
public ActionResult Error() { var model = new Models.ErrorModel(ControllerContext); if (model.StatusCode != null) { //try to locate the view for this error var result = ViewEngineCollection.FindView(ControllerContext, $"Error{model.StatusCode}", null); if (result?.View != null) //if found, execute it, decorating it with our decorator which preserves the original status code. { return(Decorate(View(result.View, model), model)); } } return(Decorate(View(model), model)); }
private Task HandleExceptionAsync(HttpContext context, Exception exception) { logger.LogError(exception, exception.Message); var errorModel = new Models.ErrorModel { Code = -1, Message = "The server encountered an internal error." }; if (exception is ProjectException || exception is TimeoutException) { context.Response.StatusCode = (int)GetHttpStatusCodeByExceptionType(exception); } else { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; errorModel.Module = exception.StackTrace; if (exception.InnerException != null) { errorModel.Detail = exception.InnerException.Message; } } if (exception is ProjectException) { var projectException = exception as ProjectException; errorModel.Code = context.Response.StatusCode; errorModel.Detail = projectException.Detail; errorModel.Module = projectException.Module; errorModel.Message = projectException.Message; if (projectException.ValidationError != null && projectException.ValidationError.Count > 0) { errorModel.ValidationError = projectException.ValidationError; } } var result = JsonConvert.SerializeObject(errorModel); context.Response.ContentType = "application/json;charset=utf-8"; return(context.Response.WriteAsync(result)); }
public override void OnActionExecuted(ActionExecutedContext filterContext) { //********************************?????????????************************/// //NOTE:PUT ERROR LOGGING CODE HERE if (filterContext.Exception != null) { DIYFEWeb.Models.ErrorModel err = new Models.ErrorModel(); err.InsertError(filterContext.Exception); filterContext.HttpContext.Trace.Write("(Logging Filter)Exception thrown"); } //****************************????********************/// //NOTE: PUT USER TRACKING CODE HERE base.OnActionExecuted(filterContext); }
public override void OnActionExecuted(ActionExecutedContext filterContext) { //********************************?????????????************************/// //NOTE:PUT ERROR LOGGING CODE HERE if (filterContext.Exception != null) { DIYFE.Web.Models.ErrorModel err = new Models.ErrorModel(); err.InsertError(filterContext.Exception); filterContext.HttpContext.Trace.Write("(Logging Filter)Exception thrown"); } //****************************????********************/// //NOTE: PUT USER TRACKING CODE HERE base.OnActionExecuted(filterContext); }
/// <summary> /// Produz o resultado bad request 400, de forma amigável /// </summary> /// <param name="errors">Coleção de erros de validação de dados.</param> public void WriteError(IReadOnlyCollection <Flunt.Notifications.Notification> errors) { var erros = new Models.ErrorModel(errors); this.ViewModel = new BadRequestObjectResult(erros); }