/// <summary> /// Altera tbModoEntradaTef /// </summary> /// <param name="param"></param> /// <returns></returns> public static void Update(string token, tbModoEntradaTef param) { try { tbModoEntradaTef value = _db.tbModoEntradaTefs .Where(e => e.cdModoEntradaTef.Equals(param.cdModoEntradaTef)) .First <tbModoEntradaTef>(); // OBSERVAÇÂO: VERIFICAR SE EXISTE ALTERAÇÃO NO PARAMETROS if (param.cdModoEntradaTef != null && param.cdModoEntradaTef != value.cdModoEntradaTef) { value.cdModoEntradaTef = param.cdModoEntradaTef; } if (param.dsModoEntradaTef != null && param.dsModoEntradaTef != value.dsModoEntradaTef) { value.dsModoEntradaTef = param.dsModoEntradaTef; } _db.SaveChanges(); } catch (Exception e) { if (e is DbEntityValidationException) { string erro = MensagemErro.getMensagemErro((DbEntityValidationException)e); throw new Exception(erro.Equals("") ? "Falha ao alterar modo entrada tef" : erro); } throw new Exception(e.InnerException == null ? e.Message : e.InnerException.InnerException == null ? e.InnerException.Message : e.InnerException.InnerException.Message); } }
// PUT /tbModoEntradaTef/token/ public HttpResponseMessage Put(string token, [FromBody] tbModoEntradaTef param) { tbLogAcessoUsuario log = new tbLogAcessoUsuario(); try { log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject(param), "Put"); HttpResponseMessage retorno = new HttpResponseMessage(); if (Permissoes.Autenticado(token)) { GatewayTbModoEntradaTef.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 TbModoEntradaTef /// </summary> /// <param name="param"></param> /// <returns></returns> public static short Add(string token, tbModoEntradaTef param) { try { _db.tbModoEntradaTefs.Add(param); _db.SaveChanges(); return(param.cdModoEntradaTef); } catch (Exception e) { if (e is DbEntityValidationException) { string erro = MensagemErro.getMensagemErro((DbEntityValidationException)e); throw new Exception(erro.Equals("") ? "Falha ao salvar modo entrada tef" : erro); } throw new Exception(e.InnerException == null ? e.Message : e.InnerException.InnerException == null ? e.InnerException.Message : e.InnerException.InnerException.Message); } }