public static bool Guardar(Usuario usuario) { using (var db = new PeliculasDb()) { try { if (Buscar(usuario.UsuarioId) == null) { db.Usuarios.Add(usuario); } else { db.Entry(usuario).State = EntityState.Modified; } db.SaveChanges(); return(true); } catch (Exception) { return(false); throw; } } }
public static bool Guardar(Pelicula pelicula) { using (var db = new PeliculasDb()) { try { if (Buscar(pelicula.PeliculaId) == null) { db.Peliculas.Add(pelicula); /*foreach (var cat in pelicula.Categorias) * { * db.Entry(cat).State = EntityState.Unchanged; * }*/ } else { db.Entry(pelicula).State = EntityState.Modified; } db.SaveChanges(); return(true); } catch (Exception) { return(false); throw; } } }
public static bool Guardar(Categoria categoria) { using (var db = new PeliculasDb()) { try { if (Buscar(categoria.CategoriaId) == null) { db.Categorias.Add(categoria); } else { db.Entry(categoria).State = EntityState.Modified; } db.SaveChanges(); return(true); } catch (Exception) { return(false); throw; } } }
public static bool Guardar(Actor actor) { using (var db = new PeliculasDb()) { try { if (Buscar(actor.ActorId) == null) { db.Actores.Add(actor); } else { db.Entry(actor).State = EntityState.Modified; } db.SaveChanges(); return(true); } catch (Exception E) { return(false); throw; } } }
private void VerListabutton_Click(object sender, EventArgs e) { List <Pelicula> peliculaLista = new List <Pelicula>(); var peliDb = new PeliculasDb(); peliculaLista = peliDb.peliculas.ToList(); VerListadataGridView.DataSource = peliculaLista; }
public static List <Pelicula> GetListDate(DateTime Desde, DateTime Hasta) { using (var db = new PeliculasDb()) { try { return(db.Peliculas.Where(P => P.Estreno >= Desde.Date && P.Estreno <= Hasta.Date).ToList()); } catch (Exception) { return(new List <Pelicula>()); throw; } } }
public static List <Pelicula> GetList() { using (var db = new PeliculasDb()) { try { return(db.Peliculas.ToList()); } catch (Exception) { return(new List <Pelicula>()); throw; } } }
public static Pelicula Buscar(int id) { using (var db = new PeliculasDb()) { try { return(db.Peliculas.Find(id)); } catch (Exception) { return(null); throw; } } }
public static List <Pelicula> GetListId(int id) { using (var db = new PeliculasDb()) { try { return(db.Peliculas.Where(P => P.PeliculaId == id).ToList()); } catch (Exception) { return(new List <Pelicula>()); throw; } } }
public static List <Pelicula> GetListDescripcion(string descripcion) { using (var db = new PeliculasDb()) { try { return(db.Peliculas.Where(P => P.Descripcion == descripcion).ToList()); } catch (Exception) { return(new List <Pelicula>()); throw; } } }
public static bool Eliminar(int id) { using (var db = new PeliculasDb()) { try { db.Entry(Buscar(id)).State = EntityState.Deleted; db.SaveChanges(); return(true); } catch (Exception) { return(false); throw; } } }
public static Pelicula Buscar(int idPelicula) { var pelicula = new Pelicula(); using (var conec = new PeliculasDb()) { try { pelicula = conec.peliculas.Find(idPelicula); } catch (Exception) { throw; } } return(pelicula); }
public static bool Eliminar(Pelicula peliculaNueva) { bool interruptor = false; using (var conec = new PeliculasDb()) { try { conec.Entry(peliculaNueva).State = EntityState.Deleted; conec.SaveChanges(); interruptor = true; } catch (Exception) { throw; } } return(interruptor); }
public static bool Guardar(Pelicula peliculaNueva) { bool interruptor = false; using (var conec = new PeliculasDb()) { try { conec.peliculas.Add(peliculaNueva); conec.SaveChanges(); interruptor = true; } catch (Exception e) { MessageBox.Show(e.ToString()); } } return(interruptor); }