Esempio n. 1
0
        public Editorial DeleteEditorial(Editorial _model)
        {
            try
            {
                context.Editorials.Remove(_model);
                context.SaveChanges();

                return(new Editorial());
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        // GET: Editoriales/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Editorial editorial = db.Editoriales.Find(id);

            if (editorial == null)
            {
                return(HttpNotFound());
            }
            return(View(editorial));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("IdEditorial,Nombre")] Editorial editorial)
        {
            if (ModelState.IsValid)
            {
                editorial.IdEditorial = Guid.NewGuid();
                _context.Add(editorial);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index),
                                        new { ac = "Registro insertado con éxito", type = "success" }));
            }

            return(View(editorial));
        }
Esempio n. 4
0
        private void OkMetroButton_Click(object sender, EventArgs e)
        {
            if (ValidarDatos())
            {
                if (editorial == null)
                {
                    editorial = new Editorial();
                }

                editorial.NombreEditorial = EditorialMetroTextBox.Text.Trim();
                editorial.Pais            = (Pais)PaisMetroComboBox.SelectedItem;
                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 5
0
        public Editorial update(Editorial editorial)
        {
            const string SQL = "actualizarEditorial";

            using (SqlConnection conexion = new SqlConnection(cadenaConexion)) {
                SqlCommand cmd = new SqlCommand(SQL, conexion);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@idEditorial", editorial.CodEditorial);
                cmd.Parameters.AddWithValue("@editorial", editorial.Nombre);
                conexion.Open();
                cmd.ExecuteNonQuery();
            }
            return(editorial);
        }
Esempio n. 6
0
        public async Task <Editorial> Update(Editorial editorial)
        {
            try
            {
                DB.Editoriales.Update(editorial);
                await DB.SaveChangesAsync();

                return(editorial);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 7
0
        public async Task <bool> Delete(Editorial editorial)
        {
            try
            {
                DB.Editoriales.Remove(editorial);
                await DB.SaveChangesAsync();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 8
0
        public Editorial Find(int EditorialId)
        {
            var result = new Editorial();

            try
            {
                result = _context.Editoriales.Single(x => x.EditorialId == EditorialId);
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
Esempio n. 9
0
 public void Agregar(Editorial editorial)
 {
     try
     {
         conexionBd  = new ConexionBd();
         repositorio = new RepositorioEditoriales(conexionBd.AbrirConexion());
         repositorio.Agregar(editorial);
         conexionBd.CerrarConexion();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public void Borrar(Editorial editorial)
 {
     try
     {
         string     cadenaComando = "DELETE FROM Editoriales WHERE EditorialId=@id";
         SqlCommand comando       = new SqlCommand(cadenaComando, _conexion);
         comando.Parameters.AddWithValue("@id", editorial.EditorialId);
         comando.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Esempio n. 11
0
 public static void Update(Editorial editorial)
 {
     try {
         using (var ctx = new BibliotecaContext()) {
             Editorial e1 = ctx.Editoriales.Where(e => e.Id == editorial.Id).FirstOrDefault();
             e1.Estado = editorial.Estado;
             e1.Nombre = editorial.Nombre;
             e1.Pais   = ctx.Paises.Where(p => p.Id == editorial.Pais.Id).FirstOrDefault();
             ctx.SaveChanges();
         }
     } catch (Exception ex) {
         throw new Exception("Ocurrio un error al obtener los datos, verifique la conexion con el servidor", ex);
     }
 }
        public bool existeEditorial(Editorial oEditorial)
        {
            IList <Editorial> editoriales = new List <Editorial>();

            editoriales = oEditorialDAO.getAll();
            foreach (Editorial a in editoriales)
            {
                if (oEditorial.Equals(a))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 13
0
        /// <summary>
        /// retorna todas las editoriales mas comodin
        /// </summary>
        /// <returns></returns>
        public List <Editorial> todosLasEditorialesFiltro()
        {
            EditorialDatos   datos       = new EditorialDatos();
            List <Editorial> miLista     = datos.listaEditorial();
            Editorial        miEditorial = new Editorial();

            miEditorial.Codigo = -1;
            miEditorial.Nombre = "Todas";

            miLista.Insert(0, miEditorial);


            return(miLista);
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            var editorial = new Editorial();

            var andrei = new Reader("Andrei");
            var marcel = new Reader("Marcel");
            var radu   = new Reader("Radu");

            editorial.AddSubscriber(andrei);
            editorial.AddSubscriber(marcel);
            editorial.AddSubscriber(radu);

            editorial.Publish(new("Real Madrid 3 - 1 Liverpool", "Hala Madrid", DateTime.Now));
        }
        public async Task <Editorial> GetEditorialData(int itemId)
        {
            try
            {
                var result = await ApiClientFactory.Instance.GetAllEditorials();

                Editorial editorial = result.Where(x => x.Id == itemId).FirstOrDefault();
                return(editorial);
            }
            catch
            {
                throw;
            }
        }
        public RetornoModel Inativar(Editorial editorial)
        {
            RetornoModel retorno = null;

            editorial.DataModificacao = DateTime.Now;

            dal.Inativar(editorial);

            if (editorial.ID > 0)
            {
                AtualizarCache(Carregar(editorial.ID));
            }

            return(retorno);
        }
        private int Salvar(Editorial editorial)
        {
            editorial.DataModificacao = DateTime.Now;
            if (editorial.ID > 0)
            {
                editorial.DataModificacao = DateTime.Now;
                dal.Atualizar(editorial);
            }
            else
            {
                editorial.ID = dal.Inserir(editorial);
            }

            return(editorial.ID);
        }
Esempio n. 18
0
        public HttpResponseMessage GetById(int id)
        {
            Editorial           editorial = eS.getById(id);
            HttpResponseMessage response;

            if (editorial != null)
            {
                response = Request.CreateResponse <Editorial>(System.Net.HttpStatusCode.OK, editorial);
            }
            else
            {
                response = Request.CreateResponse(System.Net.HttpStatusCode.NotFound);
            }
            return(response);
        }
        public void AtualizarCache(Editorial entidade)
        {
            string SQL = @"UPDATE Editorial
                              SET UsuarioID       = @UsuarioID,
                                  DataModificacao = GetDate(),
                                  ConteudoHtml    = @ConteudoHtml
                            WHERE ID = @ID;";

            using (DbConnection con = _db.CreateConnection())
            {
                con.Open();
                con.Execute(SQL, entidade);
                con.Close();
            }
        }
        public void Inativar(Editorial entidade)
        {
            string SQL = @"UPDATE Editorial
                              SET UsuarioID           = @UsuarioID,
                                  DataModificacao     = GetDate(),
                                  Inativo             = @Inativo
                            WHERE ID = @ID;";

            using (DbConnection con = _db.CreateConnection())
            {
                con.Open();
                con.Execute(SQL, entidade);
                con.Close();
            }
        }
        private Editorial ConstruirEditorial(SqlDataReader reader)
        {
            //return new Editorial
            //{
            //    EditorialId = reader.GetInt32(0),
            //    NombreEditorial = reader.GetString(1),
            //    Pais = _repositorioPais.GetPaisPorId(reader.GetInt32(2))
            //};
            Editorial e = new Editorial();

            e.EditorialId     = reader.GetInt32(0);
            e.NombreEditorial = reader.GetString(1);
            e.Pais            = repositorioPaises.GetPaisPorId(reader.GetInt32(2));
            return(e);
        }
Esempio n. 22
0
 public HttpResponseMessage Put([FromBody] Editorial editorial)
 {
     try
     {
         DbLibrary    dbLibrary   = new DbLibrary();
         BO_Editorial boEditorial = new BO_Editorial(dbLibrary);
         DataMessage  dataMessage = new DataMessage(boEditorial.Update(editorial));
         return(Request.CreateResponse(HttpStatusCode.OK, dataMessage));
     }
     catch (Exception e)
     {
         ErrorMessage mensaje = new ErrorMessage("2.1", "Excepción en la actualización del registro: " + e.GetBaseException().Message, e.ToString());
         return(Request.CreateResponse(HttpStatusCode.BadRequest, mensaje));
     }
 }
Esempio n. 23
0
        public Editorial CreateEditorial(Editorial _model)
        {
            try
            {
                context.Editorials.Add(_model);
                context.SaveChanges();

                var resultObj = context.Editorials.ToList().Last();
                return(resultObj);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 24
0
 public bool EstaRelaciona(Editorial editorial)
 {
     try
     {
         conexionBd  = new ConexionBd();
         repositorio = new RepositorioEditoriales(conexionBd.AbrirConexion());
         var relaciona = repositorio.EstaRelacionado(editorial);
         conexionBd.CerrarConexion();
         return(relaciona);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Esempio n. 25
0
        /// <summary>
        /// Reverts the delete action.
        /// </summary>
        private void RevertDelition()
        {
            Editorial editorial = UnitOfWork.EditorialRepository.FindById(Dto.Id);

            if (editorial == null)
            {
                editorial = new Editorial()
                {
                    Id = Dto.Id
                }
            }
            ;
            EMapper.MapJson(editorial, JsonOfTheEntity);
            UnitOfWork.EditorialRepository.Create(editorial);
        }
 public void Agregar(Editorial editorial)
 {
     try
     {
         string     cadenaComando = "INSERT INTO Editoriales VALUES (@nombreEditorial, @paisId)";
         SqlCommand comando       = new SqlCommand(cadenaComando, _conexion);
         comando.Parameters.AddWithValue("@nombreEditorial", editorial.NombreEditorial);
         comando.Parameters.AddWithValue("@paisId", editorial.Pais.PaisId);
         comando.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Esempio n. 27
0
        //private string cadenaConexion = ConfigurationManager.ConnectionStrings["gestionBiblioteca"].ConnectionString;
        public Editorial create(Editorial editorial)
        {
            const string SQL = "crearEditorial";

            using (SqlConnection conexion = new SqlConnection(cadenaConexion)) {
                SqlCommand cmd = new SqlCommand(SQL, conexion);
                cmd.CommandType = CommandType.StoredProcedure;
                conexion.Open();
                cmd.Parameters.AddWithValue("@editorial", editorial.Nombre);
                cmd.Parameters.Add("@idEditorial", SqlDbType.Int).Direction = ParameterDirection.Output;
                cmd.ExecuteNonQuery();
                editorial.CodEditorial = Convert.ToInt32(cmd.Parameters["@idEditorial"].Value);
            }
            return(editorial);
        }
Esempio n. 28
0
        public async Task <Editorial> Post(Editorial editorial)
        {
            try
            {
                await DB.Editoriales.AddAsync(editorial);

                await DB.SaveChangesAsync();

                return(editorial);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 29
0
        public static int Insertar(Editorial unaEditorial)
        {
            int intRegistrosAfectados            = 0;
            List <OleDbParameter> parametersList = new List <OleDbParameter>();

            // Si hay Parametros los agrego al command.
            parametersList.Add(new OleDbParameter("strId", unaEditorial.id));
            parametersList.Add(new OleDbParameter("strNombre", unaEditorial.nombre));



            intRegistrosAfectados = AccesoDatos.ExecuteNonQuery("Editorial_Insertar", parametersList);

            return(intRegistrosAfectados);
        }
Esempio n. 30
0
        /// <summary>
        /// retorna todos los libros que cumplen con el filtro
        /// </summary>
        /// <returns></returns>
        public List <Libro> seleccionarTodosLibrosFiltro(string id, string titulo, int edi, int autor)
        {
            SqlConnection con     = new SqlConnection(Conexion.Cadena);
            List <Libro>  miLista = new List <Libro>();

            try
            {
                con.Open();
                string sql = "PA_BuscarLibroConFiltro";

                SqlCommand comando = new SqlCommand(sql, con);
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@id", id);
                comando.Parameters.AddWithValue("@titulo", titulo);
                comando.Parameters.AddWithValue("@idEditorial", edi);
                comando.Parameters.AddWithValue("@idAutor", autor);


                SqlDataReader reader = comando.ExecuteReader();

                while (reader.Read())
                {
                    Libro libro = new Libro();

                    libro.Codigo           = reader["id"].ToString();
                    libro.Titulo           = reader["Titulo"].ToString();
                    libro.fechaPublicacion = (int)reader["annoPublicacion"];

                    Editorial editorial = new Editorial();
                    editorial.Codigo = (int)reader["idEditorial"];

                    libro.Editorial = new EditorialDatos().seleccionarEditorial(editorial);

                    libro.listaAutores = new DatosLibroAutor().todosLosAutoresPorLibro(libro.Codigo);

                    miLista.Add(libro);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                con.Close();
            }
            return(miLista);
        }