public void InsertarPrestamo(Model.Prestamo prestamo) { using (var context = new Model.BibliotecaContextContainer()) { try { context.PrestamoSet.Add(prestamo); context.SaveChanges(); } catch (Exception e) { throw new Exception("No se ha podido insertar el préstamo ", e); } } }
public void ActualizarPrestamo(Model.Prestamo prestamo) { using (var context = new Model.BibliotecaContextContainer()) { try { var pres = context.PrestamoSet.FirstOrDefault(x => x.PrestamoId == prestamo.PrestamoId); context.Entry(pres).State = System.Data.Entity.EntityState.Modified; context.Entry(pres).CurrentValues.SetValues(prestamo); context.SaveChanges(); } catch (Exception e) { throw new Exception("No se ha podido actualizar el préstamo ", e); } } }