public static bool Guardar(Models.CotizacionesDetalles detalle) { bool retorno = false; try { using (var db = new EjemploDetalleDb()) { if (Buscar(detalle.DetalleId) == null) { db.CotizacionDetalle.Add(detalle); } else { db.Entry(detalle).State = EntityState.Modified; } db.SaveChanges(); } retorno = true; } catch (Exception) { throw; } return(retorno); }
public static bool Eliminar(int id) { bool retorno = false; try { using (EjemploDetalleDb db = new EjemploDetalleDb()) { Models.CotizacionesDetalles user = (from c in db.CotizacionDetalle where c.DetalleId == id select c).FirstOrDefault(); db.CotizacionDetalle.Remove(user); db.SaveChanges(); retorno = true; } } catch (Exception) { throw; } return(retorno); }