/// <summary> /// Altera LogExecutionException /// </summary> /// <param name="param"></param> /// <returns></returns> public static void Update(string token, LogExecutionException param) { try { LogExecutionException value = _db.LogExecutionExceptions .Where(e => e.id.Equals(param.id)) .First <LogExecutionException>(); // OBSERVAÇÂO: VERIFICAR SE EXISTE ALTERAÇÃO NO PARAMETROS if (param.id != null && param.id != value.id) { value.id = param.id; } if (param.idLogExecution != null && param.idLogExecution != value.idLogExecution) { value.idLogExecution = param.idLogExecution; } if (param.textError != null && param.textError != value.textError) { value.textError = param.textError; } _db.SaveChanges(); } catch (Exception e) { if (e is DbEntityValidationException) { string erro = MensagemErro.getMensagemErro((DbEntityValidationException)e); throw new Exception(erro.Equals("") ? "Falha ao alterar logexecutionexception" : erro); } throw new Exception(e.InnerException == null ? e.Message : e.InnerException.InnerException == null ? e.InnerException.Message : e.InnerException.InnerException.Message); } }
// PUT /LogExecutionException/token/ public HttpResponseMessage Put(string token, [FromBody] LogExecutionException param) { tbLogAcessoUsuario log = new tbLogAcessoUsuario(); try { log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject(param), "Put"); HttpResponseMessage retorno = new HttpResponseMessage(); if (Permissoes.Autenticado(token)) { GatewayLogExecutionException.Update(token, param); log.codResposta = (int)HttpStatusCode.OK; Bibliotecas.LogAcaoUsuario.Save(log); return(Request.CreateResponse(HttpStatusCode.OK)); } else { log.codResposta = (int)HttpStatusCode.Unauthorized; Bibliotecas.LogAcaoUsuario.Save(log); return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } } catch (Exception e) { log.codResposta = (int)HttpStatusCode.InternalServerError; log.msgErro = e.Message; Bibliotecas.LogAcaoUsuario.Save(log); throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
/// <summary> /// Adiciona nova LogExecutionException /// </summary> /// <param name="param"></param> /// <returns></returns> public static Int32 Add(string token, LogExecutionException param) { try { _db.LogExecutionExceptions.Add(param); _db.SaveChanges(); return(param.id); } catch (Exception e) { if (e is DbEntityValidationException) { string erro = MensagemErro.getMensagemErro((DbEntityValidationException)e); throw new Exception(erro.Equals("") ? "Falha ao listar logexecutionexception" : erro); } throw new Exception(e.InnerException == null ? e.Message : e.InnerException.InnerException == null ? e.InnerException.Message : e.InnerException.InnerException.Message); } }