public Ca_Rubros ObtenerRubro(int id, int idInst) { Ca_Rubros list = new Ca_Rubros(); try { if (id == 0) { list.Id_Institucion = idInst; return(list); } using (ClusmextContext context = new ClusmextContext()) { list = context.Ca_Rubros.Where(x => x.Id_Rubro == id).SingleOrDefault(); list.Id_Institucion = idInst; } } catch (Exception ex) { } return(list); }
public int GuardarRubro(Ca_Rubros rb) { int val = 0; try { using (ClusmextContext context = new ClusmextContext()) { if (rb.Id_Rubro > 0) { context.Entry(rb).State = EntityState.Modified; } else { context.Entry(rb).State = EntityState.Added; } val = context.SaveChanges(); } } catch (Exception ex) { } return(val); }