public void Guardar(Pais pais) { try { if (pais.PaisId == 0) { _dbContext.Paises.Add(pais); } else { var paisInDb = _dbContext.Paises.SingleOrDefault(p => p.PaisId == pais.PaisId); if (paisInDb != null) { paisInDb.Nombre = pais.Nombre; _dbContext.Entry(paisInDb).State = EntityState.Modified; } else { throw new Exception("País inexistente"); } } } catch (Exception e) { throw new Exception(e.Message); } }
public void Guardar(Soporte soporte) { try { if (soporte.SoporteId == 0) { _dbContext.Soportes.Add(soporte); } else { var soporteInDb = _dbContext.Soportes.SingleOrDefault(p => p.SoporteId == soporte.SoporteId); if (soporteInDb != null) { soporteInDb.Descripcion = soporte.Descripcion; _dbContext.Entry(soporteInDb).State = EntityState.Modified; } else { throw new Exception("Soporte inexistente"); } } } catch (Exception e) { throw new Exception(e.Message); } }
public void Guardar(Estilo estilo) { try { if (estilo.EstiloId == 0) { _dbContext.Estilos.Add(estilo); } else { _dbContext.Estilos.Attach(estilo); _dbContext.Entry(estilo).State = EntityState.Modified; } } catch (Exception e) { throw new Exception(e.Message); } }
public void Guardar(Album album) { try { if (album.AlbumId == 0) { _dbContext.Albumes.Add(album); } else { _dbContext.Albumes.Attach(album); _dbContext.Entry(album).State = EntityState.Modified; } } catch (Exception e) { throw new Exception(e.Message); } }
public void Guardar(Tema tema) { try { if (tema.TemaId == 0) { _dbContext.Temas.Add(tema); } else { //TODO:Ver como hacer para los casos de edición _dbContext.Temas.Attach(tema); _dbContext.Entry(tema).State = EntityState.Modified; } } catch (Exception e) { throw new Exception(e.Message); } }
public void Borrar(Interprete interprete) { try { var interpreteInDb = _dbContext.Interpretes.SingleOrDefault(i => i.InterpreteId == interprete.InterpreteId); if (interpreteInDb != null) { _dbContext.Entry(interpreteInDb).State = EntityState.Deleted; } } catch (Exception ex) { throw new Exception(ex.Message); } }
public void Guardar(Negocio negocio) { try { if (negocio.NegocioId == 0) { _dbContext.Negocios.Add(negocio); } else { _dbContext.Negocios.Attach(negocio); _dbContext.Entry(negocio).State = EntityState.Modified; } } catch (Exception e) { throw new Exception(e.Message); } }