public int insertComment(ModeloNegocio.Comment ObjComment) { try { Cmd = new SqlCommand(); Cmd.Connection = Conn; Cmd.Parameters.Clear(); Cmd.CommandType = CommandType.StoredProcedure; Cmd.CommandText = "PA_ING_COMMENT"; Cmd.Parameters.Add("@email_author", SqlDbType.VarChar).Value = ObjComment.EmailAuthor; Cmd.Parameters.Add("@comment", SqlDbType.Text).Value = ObjComment.CommentContent; Cmd.Parameters.Add("@id_content", SqlDbType.VarChar).Value = ObjComment.IdCotent; Cmd.Parameters.Add("@ip_author", SqlDbType.VarChar).Value = ObjComment.IpAuthor; Cmd.Parameters.Add("@id", SqlDbType.Int).Direction = ParameterDirection.Output; Cmd.ExecuteNonQuery(); ObjComment.Id = Convert.ToInt32(Cmd.Parameters["@id"].Value); Conn.Close(); return(ObjComment.Id); } catch (Exception e) { // Console.WriteLine("{0} Problem insert.", e); //throw new Exception("Error en Acceso a Datos: InsertarMonto.", e); return(0); } //throw new NotImplementedException(); }
protected void cmdGuardar_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.Params["id"]); objCommentMN = new ModeloNegocio.Comment(); objCommentLN = new LogicaNegocio.Comment(); String IPAdd ; IPAdd = Request.UserHostAddress; //If String.IsNullOrEmpty(IPAdd) Then // IPAdd = Request.ServerVariables("REMOTE_ADDR") // lblIPBehindProxy.Text = IPAdd //End If objCommentMN.CommentContent = txtComentario.Text; objCommentMN.EmailAuthor = txtEmail.Text; objCommentMN.IdCotent = id ; objCommentMN.IpAuthor = IPAdd; objCommentLN.insertComment(objCommentMN); string strRedirect; strRedirect = "noticia-detalle.aspx?id=" + id.ToString(); Response.Redirect(strRedirect, true); }
protected void cmdGuardar_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.Params["id"]); objCommentMN = new ModeloNegocio.Comment(); objCommentLN = new LogicaNegocio.Comment(); String IPAdd; IPAdd = Request.UserHostAddress; //If String.IsNullOrEmpty(IPAdd) Then // IPAdd = Request.ServerVariables("REMOTE_ADDR") // lblIPBehindProxy.Text = IPAdd //End If objCommentMN.CommentContent = txtComentario.Text; objCommentMN.EmailAuthor = txtEmail.Text; objCommentMN.IdCotent = id; objCommentMN.IpAuthor = IPAdd; objCommentLN.insertComment(objCommentMN); string strRedirect; strRedirect = "noticia-detalle.aspx?id=" + id.ToString(); Response.Redirect(strRedirect, true); }
/// <summary> /// getCommentId Metodo obtiene un Comentarios según su ID /// </summary> /// <param name="id">Id del Comentarios </param> /// <returns>Retorna un List ModeloNegocio.Comment</returns> public ModeloNegocio.Comment getCommentId(int id) { try { ModeloNegocio.Comment comment = new ModeloNegocio.Comment(); Cmd = new SqlCommand(); Cmd.Connection = Conn; Cmd.CommandText = "SELECT otaku_bcp.comment.comment, otaku_bcp.comment.id, otaku_bcp.comment.email_author, otaku_bcp.comment.created_at, otaku_bcp.comment.updated_at , otaku_bcp.comment.id_content, otaku_bcp.comment.ip_author FROM otaku_bcp.comment WHERE otaku_bcp.comment.id = @id"; Cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.Int)); Cmd.Parameters["@id"].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"]))); comment.Id = Convert.ToInt32(Dtr["id"]); comment.CommentContent = Convert.ToString(Dtr["comment"]); comment.EmailAuthor = Convert.ToString(Dtr["email_author"]); if (DBNull.Value.Equals(Dtr["created_at"])) { comment.Created_at = DateTime.Now; } else { comment.Created_at = Convert.ToDateTime(Dtr["created_at"]); } if (DBNull.Value.Equals(Dtr["created_at"])) { comment.Updated_at = DateTime.Now; } else { comment.Updated_at = Convert.ToDateTime(Dtr["updated_at"]); } comment.IdCotent = Convert.ToInt16(Dtr["id_content"]); comment.IpAuthor = Convert.ToString(Dtr["ip_author"]); } Cmd.Parameters.Clear(); Dtr.Close(); Conn.Close(); return(comment); } catch (Exception ex) { throw new Exception("Error en Acceso a Datos: LoginUsuario.", ex); } }
/// <summary> /// getCommentId Metodo obtiene un Comentarios según su ID /// </summary> /// <param name="id">Id del Comentarios </param> /// <returns>Retorna un List ModeloNegocio.Comment</returns> public ModeloNegocio.Comment getCommentId(int id) { try { ModeloNegocio.Comment comment = new ModeloNegocio.Comment(); Cmd = new SqlCommand(); Cmd.Connection = Conn; Cmd.CommandText = "SELECT otaku_bcp.comment.comment, otaku_bcp.comment.id, otaku_bcp.comment.email_author, otaku_bcp.comment.created_at, otaku_bcp.comment.updated_at , otaku_bcp.comment.id_content, otaku_bcp.comment.ip_author FROM otaku_bcp.comment WHERE otaku_bcp.comment.id = @id"; Cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.Int)); Cmd.Parameters["@id"].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"]))); comment.Id = Convert.ToInt32(Dtr["id"]); comment.CommentContent = Convert.ToString(Dtr["comment"]); comment.EmailAuthor = Convert.ToString(Dtr["email_author"]); if (DBNull.Value.Equals(Dtr["created_at"])) { comment.Created_at = DateTime.Now; } else { comment.Created_at = Convert.ToDateTime(Dtr["created_at"]); } if (DBNull.Value.Equals(Dtr["created_at"])) { comment.Updated_at = DateTime.Now; } else { comment.Updated_at = Convert.ToDateTime(Dtr["updated_at"]); } comment.IdCotent = Convert.ToInt16(Dtr["id_content"]); comment.IpAuthor = Convert.ToString(Dtr["ip_author"]); } Cmd.Parameters.Clear(); Dtr.Close(); Conn.Close(); return comment; } catch (Exception ex) { throw new Exception("Error en Acceso a Datos: LoginUsuario.", ex); } }
// 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> /// getAllCommentContent Metodo obtiene todos los Comentarios de un contenido /// </summary> /// <param name="idContent">Id del contenido el cual se mostrará todos sus commentarios</param> /// <returns>Retorna un List ModeloNegocio.Comment</returns> public List<ModeloNegocio.Comment> getAllCommentContentId(int idContent) { List<ModeloNegocio.Comment> lista = new List<ModeloNegocio.Comment>(); try { Cmd = new SqlCommand(); Cmd.Connection = Conn; Cmd.CommandType = CommandType.StoredProcedure; Cmd.CommandText = "PA_GET_COMENT_CONTENT"; Cmd.Parameters.Add("@idContent", SqlDbType.Int).Value = idContent; Dtr = Cmd.ExecuteReader(); while (Dtr.Read()) { ModeloNegocio.Comment comment = new ModeloNegocio.Comment(); comment.Id = Convert.ToInt32(Dtr["id"]); comment.CommentContent = Convert.ToString(Dtr["comment"]); comment.EmailAuthor = Convert.ToString(Dtr["email_author"]); comment.Created_at = Convert.ToDateTime(Dtr["created_at"]); comment.Updated_at = Convert.ToDateTime(Dtr["updated_at"]); comment.IdCotent = Convert.ToInt16(Dtr["id_content"]); comment.IpAuthor = Convert.ToString(Dtr["ip_author"]); lista.Add(comment); } //Cmd.Parameters.Clear(); //Dtr.Close(); Conn.Close(); return lista; } catch (Exception ex) { throw new Exception("Error en Acceso a Datos: LoginUsuario.", ex); } }
/// <summary> /// getAllCommentContent Metodo obtiene todos los Comentarios de un contenido /// </summary> /// <param name="idContent">Id del contenido el cual se mostrará todos sus commentarios</param> /// <returns>Retorna un List ModeloNegocio.Comment</returns> public List <ModeloNegocio.Comment> getAllCommentContentId(int idContent) { List <ModeloNegocio.Comment> lista = new List <ModeloNegocio.Comment>(); try { Cmd = new SqlCommand(); Cmd.Connection = Conn; Cmd.CommandType = CommandType.StoredProcedure; Cmd.CommandText = "PA_GET_COMENT_CONTENT"; Cmd.Parameters.Add("@idContent", SqlDbType.Int).Value = idContent; Dtr = Cmd.ExecuteReader(); while (Dtr.Read()) { ModeloNegocio.Comment comment = new ModeloNegocio.Comment(); comment.Id = Convert.ToInt32(Dtr["id"]); comment.CommentContent = Convert.ToString(Dtr["comment"]); comment.EmailAuthor = Convert.ToString(Dtr["email_author"]); comment.Created_at = Convert.ToDateTime(Dtr["created_at"]); comment.Updated_at = Convert.ToDateTime(Dtr["updated_at"]); comment.IdCotent = Convert.ToInt16(Dtr["id_content"]); comment.IpAuthor = Convert.ToString(Dtr["ip_author"]); lista.Add(comment); } //Cmd.Parameters.Clear(); //Dtr.Close(); Conn.Close(); return(lista); } catch (Exception ex) { throw new Exception("Error en Acceso a Datos: LoginUsuario.", ex); } }
public int insertComment(ModeloNegocio.Comment ObjComment) { return(objCommentAD.insertComment(ObjComment)); }
public Comment() { objCommentAD = new AccesoDatos.Comment(); objContentMN = new ModeloNegocio.Comment(); }