public static void InsertarAutor(string Nautor) { try { AutorPatron TAutPat = new AutorPatron(); TAutPat.NombreAutor = Nautor != string.Empty ? Nautor : null; PatronEntit.Instancia.AutorPatron.Add(TAutPat); PatronEntit.Instancia.SaveChanges(); cResultException = null; cSuccessful = true; } catch (Exception ex) { cResultException = ex.ToString(); cSuccessful = false; } }
public static void EliminarAutor(int idregistro) { try { var cliente = new AutorPatron { IdAutorPatron = idregistro }; contexto.AutorPatron.Attach(cliente); contexto.AutorPatron.Remove(cliente); contexto.SaveChanges(); cResultException = null; cSuccessful = true; } catch (Exception ex) { cResultException = ex.ToString(); cSuccessful = false; } }
public static void ModificarAutor(int idregistro, string autorModificado) { try { var cliente = new AutorPatron { IdAutorPatron = idregistro }; contexto.AutorPatron.Attach(cliente); cliente.NombreAutor = autorModificado; contexto.Configuration.ValidateOnSaveEnabled = false; contexto.SaveChanges(); cResultException = null; cSuccessful = true; } catch (Exception ex) { cResultException = ex.ToString(); cSuccessful = false; } }