public void InsertarEditorial(Model.Editorial editorial) { using (var context = new Model.BibliotecaContextContainer()) { try { context.EditorialSet.Add(editorial); context.SaveChanges(); } catch (Exception e) { throw new Exception("No se ha podido insertar la editorial ", e); } } }
public void ActualizarEditorial(Model.Editorial editorial) { using (var context = new Model.BibliotecaContextContainer()) { try { var edi = context.EditorialSet.FirstOrDefault(x => x.EditorialId == editorial.EditorialId); context.Entry(edi).State = System.Data.Entity.EntityState.Modified; context.Entry(edi).CurrentValues.SetValues(editorial); context.SaveChanges(); } catch (Exception e) { throw new Exception("No se ha podido actualizar la editorial ", e); } } }