public int Gravar(Status s) { if (!string.IsNullOrEmpty(s.sta_status.Trim())) { try { using (HelpDeskEntities contexto = new HelpDeskEntities(Util.StrConection)) { if(s.sta_codigo == 0) contexto.Status.Add(s); else { contexto.Entry(s).State = System.Data.EntityState.Modified; } return contexto.SaveChanges(); } } catch (Exception) { return -1; } } return -2; }
public int Gravar(Status s) { if (s.Descricao.Trim() != string.Empty) { try { using (HelpDeskEntities contexto = new HelpDeskEntities(Util.StringConexao)) { if (s.Codigo == 0) contexto.Status.Add(s); else contexto.Entry(s).State = System.Data.EntityState.Modified; return contexto.SaveChanges(); } } catch (Exception) { return -1; } } else return -2; }