public List<ModeloNegocio.Content> getAllContent(int registroAMostrar, int registroAEmpezar, int idType) { List<ModeloNegocio.Content> lista = new List<ModeloNegocio.Content>(); Cmd = new SqlCommand(); Cmd.Connection = Conn; try { Cmd.CommandType = CommandType.StoredProcedure; Cmd.CommandText = "PA_LISTA_CONTENT"; Cmd.Parameters.Add("@RegistrosAMostrar", SqlDbType.Int).Value = registroAMostrar; Cmd.Parameters.Add("@RegistrosAEmpezar", SqlDbType.Int).Value = registroAEmpezar; Cmd.Parameters.Add("@idType", SqlDbType.Int).Value = idType; Dtr = Cmd.ExecuteReader(); while (Dtr.Read()) { ModeloNegocio.Content content = new ModeloNegocio.Content(); content.Id = Convert.ToInt32(Dtr["id"]); content.Title = Dtr["title"].ToString(); content.ContentNote = Dtr["content"].ToString(); //users.Type = Dtr["type"].ToString(); content.IdUser = Convert.ToInt32(Dtr["iduser"].ToString()); content.IdType = Convert.ToInt32(Dtr["idtype"].ToString()); content.Image = Dtr["image"].ToString(); if (DBNull.Value.Equals(Dtr["created_at"])) { content.Created_at = DateTime.Now; } else { content.Created_at = Convert.ToDateTime(Dtr["created_at"]); } if (DBNull.Value.Equals(Dtr["updated_at"])) { content.Updated_at = DateTime.Now; } else { content.Updated_at = Convert.ToDateTime(Dtr["updated_at"]); } //ModeloNegocio.TypeUser typeUser = new ModeloNegocio.TypeUser(); //typeUser.Id = Convert.ToInt16(Dtr["type_user_id"]); //typeUser.Name = Dtr["tipoUser"].ToString(); //content.typeUser = typeUser; lista.Add(content); } Conn.Close(); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } return lista; }
// private ModeloNegocio.Comment objCommentMN; protected void Page_Load(object sender, EventArgs e) { //Si no autentificado redirecciona a Login if (!this.Page.User.Identity.IsAuthenticated) { FormsAuthentication.RedirectToLoginPage(); } if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.Params["id"])) { id = Convert.ToInt32(Request.Params["id"]); objContentMN = new ModeloNegocio.Content(); objContentLN = new LogicaNegocio.Content(); objContentMN = objContentLN.getContentId(id); objCommentMN = new ModeloNegocio.Comment(); string imagen = ""; if (!string.IsNullOrEmpty(objContentMN.Image)) { imagen = "<img class=\"img-responsive\" src=\"http://contigoentusfinanzasenaula.com/media/images/" + objContentMN.Image + " \" />"; } lblDetalleNoticia.Text += "<h1>" + objContentMN.Title + "</h1>"; lblDetalleNoticia.Text += imagen; lblDetalleNoticia.Text += objContentMN.ContentNote; List <ModeloNegocio.Comment> lista = objContentMN.Comment; if (lista.Count > 0) { foreach (ModeloNegocio.Comment comment in lista) { lblComentario.Text += "<blockquote>"; lblComentario.Text += "<h4>Correo: " + comment.EmailAuthor + " <small>Fecha: " + comment.Created_at + "</small></h4>"; lblComentario.Text += "<p>" + comment.CommentContent + "</p>"; lblComentario.Text += "</blockquote>"; } } } } }
// private ModeloNegocio.Comment objCommentMN; protected void Page_Load(object sender, EventArgs e) { //Si no autentificado redirecciona a Login if (!this.Page.User.Identity.IsAuthenticated) { FormsAuthentication.RedirectToLoginPage(); } if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.Params["id"])) { id= Convert.ToInt32(Request.Params["id"]); objContentMN = new ModeloNegocio.Content(); objContentLN = new LogicaNegocio.Content(); objContentMN = objContentLN.getContentId(id); objCommentMN = new ModeloNegocio.Comment(); string imagen = ""; if (!string.IsNullOrEmpty(objContentMN.Image)) { imagen = "<img class=\"img-responsive\" src=\"http://contigoentusfinanzasenaula.com/media/images/" + objContentMN.Image + " \" />"; } lblDetalleNoticia.Text += "<h1>" + objContentMN.Title + "</h1>"; lblDetalleNoticia.Text += imagen ; lblDetalleNoticia.Text += objContentMN.ContentNote ; List<ModeloNegocio.Comment> lista = objContentMN.Comment; if (lista.Count > 0) { foreach (ModeloNegocio.Comment comment in lista) { lblComentario.Text += "<blockquote>"; lblComentario.Text += "<h4>Correo: " + comment.EmailAuthor + " <small>Fecha: " + comment.Created_at + "</small></h4>"; lblComentario.Text += "<p>" + comment.CommentContent + "</p>"; lblComentario.Text += "</blockquote>"; } } } } }
/// <summary> /// getContentId Metodo obtiene un Contenido según su ID /// </summary> /// <param name="id">Id del Contenido </param> /// <returns>Retorna un List ModeloNegocio.Content</returns> public ModeloNegocio.Content getContentId(int id) { objMNContent = objADContent.getContentId(id); return(objMNContent); }
public Content() { objADContent = new AccesoDatos.Content(); objMNContent = new ModeloNegocio.Content(); }
/// <summary> /// getContentId Metodo obtiene un Contenido según su ID /// </summary> /// <param name="id">Id del Contenido </param> /// <returns>Retorna un List ModeloNegocio.Content</returns> public ModeloNegocio.Content getContentId(int id) { objMNContent= objADContent.getContentId(id); return objMNContent; }
public Content() { objADContent = new AccesoDatos.Content(); objMNContent = new ModeloNegocio.Content(); }
/// <summary> /// getContentId Metodo obtiene un Contenido según su ID /// </summary> /// <param name="id">Id del Contenido </param> /// <returns>Retorna un List ModeloNegocio.Content</returns> public ModeloNegocio.Content getContentId(int id) { try { ModeloNegocio.Content content = new ModeloNegocio.Content(); Cmd = new SqlCommand(); Cmd.Connection = Conn; Cmd.CommandType = CommandType.StoredProcedure; Cmd.CommandText = "PA_GET_CONTENT_ID"; Cmd.Parameters.Add("@id", SqlDbType.Int).Value = id; Dtr = Cmd.ExecuteReader(); while (Dtr.Read()) { //Lista.Add(new EntidadNegocio.UsuarioEN(Convert.ToInt32(Dtr["idusuario"]), Dtr["nombre"].ToString(), Dtr["usuario"].ToString(), Dtr["password"].ToString(), Convert.ToInt32(Dtr["permiso"]))); content.Id = Convert.ToInt32(Dtr["id"]); content.Title = Convert.ToString(Dtr["title"]); content.ContentNote = Convert.ToString(Dtr["content"]); if (DBNull.Value.Equals(Dtr["image"])) { content.Image = null; } else { content.Image = Dtr["image"].ToString(); } if (DBNull.Value.Equals(Dtr["created_at"])) { content.Created_at = DateTime.Now; } else { content.Created_at = Convert.ToDateTime(Dtr["created_at"]); } if (DBNull.Value.Equals(Dtr["updated_at"])) { content.Updated_at = DateTime.Now; } else { content.Updated_at = Convert.ToDateTime(Dtr["updated_at"]); } ModeloNegocio.User user = new ModeloNegocio.User(); user.id = Convert.ToInt32(Dtr["iduser"]); user.FullName = Convert.ToString(Dtr["user_name"]); content.User = user; ModeloNegocio.TypeContent typeContent = new ModeloNegocio.TypeContent(); typeContent.Id = Convert.ToInt32(Dtr["idtype"]); typeContent.Name = Convert.ToString(Dtr["type_content_name"]); content.typeContent = typeContent; AccesoDatos.Comment comment = new AccesoDatos.Comment(); List <ModeloNegocio.Comment> lista = new List <ModeloNegocio.Comment>(); lista = comment.getAllCommentContentId(Convert.ToInt32(Dtr["id"])); content.Comment = lista; ModeloNegocio.TypeUser typeUser = new ModeloNegocio.TypeUser(); typeUser.Id = Convert.ToInt32(Dtr["idtype"]); typeUser.Name = Convert.ToString(Dtr["type_content_name"]); } Cmd.Parameters.Clear(); Dtr.Close(); Conn.Close(); return(content); } catch (Exception ex) { throw new Exception("Error en Acceso a Datos: LoginUsuario.", ex); } }
public List <ModeloNegocio.Content> getAllContent(int registroAMostrar, int registroAEmpezar, int idType) { List <ModeloNegocio.Content> lista = new List <ModeloNegocio.Content>(); Cmd = new SqlCommand(); Cmd.Connection = Conn; try { Cmd.CommandType = CommandType.StoredProcedure; Cmd.CommandText = "PA_LISTA_CONTENT"; Cmd.Parameters.Add("@RegistrosAMostrar", SqlDbType.Int).Value = registroAMostrar; Cmd.Parameters.Add("@RegistrosAEmpezar", SqlDbType.Int).Value = registroAEmpezar; Cmd.Parameters.Add("@idType", SqlDbType.Int).Value = idType; Dtr = Cmd.ExecuteReader(); while (Dtr.Read()) { ModeloNegocio.Content content = new ModeloNegocio.Content(); content.Id = Convert.ToInt32(Dtr["id"]); content.Title = Dtr["title"].ToString(); content.ContentNote = Dtr["content"].ToString(); //users.Type = Dtr["type"].ToString(); content.IdUser = Convert.ToInt32(Dtr["iduser"].ToString()); content.IdType = Convert.ToInt32(Dtr["idtype"].ToString()); content.Image = Dtr["image"].ToString(); if (DBNull.Value.Equals(Dtr["created_at"])) { content.Created_at = DateTime.Now; } else { content.Created_at = Convert.ToDateTime(Dtr["created_at"]); } if (DBNull.Value.Equals(Dtr["updated_at"])) { content.Updated_at = DateTime.Now; } else { content.Updated_at = Convert.ToDateTime(Dtr["updated_at"]); } //ModeloNegocio.TypeUser typeUser = new ModeloNegocio.TypeUser(); //typeUser.Id = Convert.ToInt16(Dtr["type_user_id"]); //typeUser.Name = Dtr["tipoUser"].ToString(); //content.typeUser = typeUser; lista.Add(content); } Conn.Close(); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } return(lista); }
/// <summary> /// getContentId Metodo obtiene un Contenido según su ID /// </summary> /// <param name="id">Id del Contenido </param> /// <returns>Retorna un List ModeloNegocio.Content</returns> public ModeloNegocio.Content getContentId(int id) { try { ModeloNegocio.Content content = new ModeloNegocio.Content(); Cmd = new SqlCommand(); Cmd.Connection = Conn; Cmd.CommandType = CommandType.StoredProcedure; Cmd.CommandText = "PA_GET_CONTENT_ID"; Cmd.Parameters.Add("@id", SqlDbType.Int).Value = id; Dtr = Cmd.ExecuteReader(); while (Dtr.Read()) { //Lista.Add(new EntidadNegocio.UsuarioEN(Convert.ToInt32(Dtr["idusuario"]), Dtr["nombre"].ToString(), Dtr["usuario"].ToString(), Dtr["password"].ToString(), Convert.ToInt32(Dtr["permiso"]))); content.Id = Convert.ToInt32(Dtr["id"]); content.Title = Convert.ToString(Dtr["title"]); content.ContentNote = Convert.ToString(Dtr["content"]); if (DBNull.Value.Equals(Dtr["image"])) { content.Image = null; } else { content.Image = Dtr["image"].ToString() ; } if (DBNull.Value.Equals(Dtr["created_at"])) { content.Created_at = DateTime.Now; } else { content.Created_at = Convert.ToDateTime(Dtr["created_at"]); } if (DBNull.Value.Equals(Dtr["updated_at"])) { content.Updated_at = DateTime.Now; } else { content.Updated_at = Convert.ToDateTime(Dtr["updated_at"]); } ModeloNegocio.User user = new ModeloNegocio.User(); user.id = Convert.ToInt32(Dtr["iduser"]); user.FullName = Convert.ToString(Dtr["user_name"]); content.User=user; ModeloNegocio.TypeContent typeContent = new ModeloNegocio.TypeContent(); typeContent.Id = Convert.ToInt32(Dtr["idtype"]); typeContent.Name = Convert.ToString(Dtr["type_content_name"]); content.typeContent=typeContent; AccesoDatos.Comment comment = new AccesoDatos.Comment(); List<ModeloNegocio.Comment> lista = new List<ModeloNegocio.Comment>(); lista=comment.getAllCommentContentId(Convert.ToInt32(Dtr["id"])); content.Comment = lista; ModeloNegocio.TypeUser typeUser = new ModeloNegocio.TypeUser(); typeUser.Id = Convert.ToInt32(Dtr["idtype"]); typeUser.Name = Convert.ToString(Dtr["type_content_name"]); } Cmd.Parameters.Clear(); Dtr.Close(); Conn.Close(); return content; } catch (Exception ex) { throw new Exception("Error en Acceso a Datos: LoginUsuario.", ex); } }