protected void Page_Load(object sender, EventArgs e)
        {
            /* Hide the links */
            lnkAnterior.Visible  = false;
            lnkSiguiente.Visible = false;

            /* Get de Service */
            IUnityContainer  container       = (IUnityContainer)HttpContext.Current.Application["unityContainer"];
            IOpinadorService opinadorService = container.Resolve <IOpinadorService>();

            int    startIndex;
            string tag   = Request.Params.Get("tag");
            Int32  count = 5;

            try
            {
                startIndex = Int32.Parse(Request.Params.Get("startIndex"));
            }
            catch (ArgumentNullException)
            {
                startIndex = 0;
            }
            int numeroDeComentarios = opinadorService.FindComentariosByEtiqueta(tag, startIndex, count).Count();

            if (numeroDeComentarios == 0)
            {
                lblNoComments.Visible = true;
            }

            List <Comentario> comentarios = opinadorService.FindComentariosByEtiqueta(tag, startIndex, count);

            foreach (Comentario c in comentarios)
            {
                c.UserProfileReference.Load();
            }
            this.gvComments.DataSource = comentarios;
            this.gvComments.DataBind();

            /* "Previous" link */
            if ((startIndex - count) >= 0)
            {
                String url = "./ShowCommentsByTag.aspx?tag=" + tag + "&startIndex=" + (startIndex - count);

                this.lnkAnterior.NavigateUrl = Response.ApplyAppPathModifier(url);
                this.lnkAnterior.Visible     = true;
            }

            /* "Next" link */
            if ((startIndex + count) < numeroDeComentarios)
            {
                String url = "./ShowCommentsByTag.aspx" + "?tag=" + tag + "&startIndex=" + (startIndex + count);
                this.lnkSiguiente.NavigateUrl = Response.ApplyAppPathModifier(url);
                this.lnkSiguiente.Visible     = true;
            }
        }
Exemplo n.º 2
0
        public void FindComentariosByEtiquetaIdTest()
        {
            UserProfile   userProfile = CreateTestUserProfile();
            List <String> l1          = new List <String>();

            l1.Add("Office");
            l1.Add("General");
            ComentarioEtiquetaBlock comEtiBlo = opinadorService.AddComentarioEtiqueta(userProfile.usrId, PRODUCTO_ID, "texto1", l1);

            opinadorService.AddComentarioEtiqueta(userProfile.usrId, PRODUCTO_ID, "texto2", l1);
            opinadorService.AddComentarioEtiqueta(userProfile.usrId, PRODUCTO_ID, "texto3", null);

            List <Comentario> comments = opinadorService.FindComentariosByEtiqueta("Office", START_INDEX, COUNT);

            Assert.IsTrue(comments.Count == 2);
        }