public static TempoExame BuscarPeloId(string id) { TempoExame ret = null; using (var db = new ProjectoBaseDataContext()) { ret = db.TempoExames .Where(q => q.Id == id) .AsNoTracking() .FirstOrDefault(); } return(ret); }
public static string Salvar(TempoExame tempoExame) { var ret = string.Empty; using (var db = new ProjectoBaseDataContext()) { var model = BuscarPeloId(tempoExame.Id); if (model == null) { db.TempoExames.Add(tempoExame); } else { db.Entry(tempoExame).State = EntityState.Modified; } db.SaveChanges(); ret = tempoExame.Id; } return(ret); }