예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int    startIndex;
            string vendedorId = Request.Params.Get("vendedor");

            try
            {
                startIndex = Int32.Parse(Request.Params.Get("startIndex"));
            }
            catch (ArgumentNullException)
            {
                startIndex = 0;
            }

            int count = 10;
            /* Get de Service */
            IUnityContainer  container       = (IUnityContainer)HttpContext.Current.Application["unityContainer"];
            IOpinadorService opinadorService = container.Resolve <IOpinadorService>();
            ValoracionBlock  valoraciones    = new ValoracionBlock(null, 0, 0);

            cellLoginName.Text = vendedorId;
            try
            {
                valoraciones = opinadorService.FindValoracionesAndNoteByVendedor(vendedorId, startIndex, count);
            }
            catch (InstanceNotFoundException)
            {
                cellAverage.Visible = false;
            }

            cellAverage.Text      = valoraciones.AverageValoracion.ToString();
            cellNumerOfVotes.Text = valoraciones.NumValoraciones.ToString();
        }
        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>();
            ValoracionBlock  valoracionesB   = new ValoracionBlock(null, 0, 0);


            int    startIndex;
            string vendedorId = Request.Params.Get("vendedorId");

            try
            {
                startIndex = Int32.Parse(Request.Params.Get("startIndex"));
            }
            catch (ArgumentNullException)
            {
                startIndex = 0;
            }

            Int32 count = 10;

            valoracionesB = opinadorService.FindValoracionesAndNoteByVendedor(vendedorId, startIndex, count);
            int numValor = valoracionesB.NumValoraciones;

            if (numValor == 0)
            {
                lblNoValoraciones.Visible = true;
            }
            foreach (Valoracion c in valoracionesB.Valoraciones)
            {
                c.UserProfileReference.Load();
            }

            this.gvValoraciones.DataSource = valoracionesB.Valoraciones;
            this.gvValoraciones.DataBind();

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

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

            /* "Next" link */
            if ((startIndex + count) < numValor)
            {
                String url = "./ShowValoraciones.aspx" + "?vendedorId=" + vendedorId + "&startIndex=" + (startIndex + count);
                this.lnkSiguiente.NavigateUrl = Response.ApplyAppPathModifier(url);
                this.lnkSiguiente.Visible     = true;
            }
        }
예제 #3
0
        public void FindValoracionesAndNoteByVendedorTest()
        {
            UserProfile userProfile = CreateTestUserProfile();
            Valoracion  v1          = opinadorService.ValorarUsuario(VENDEDOR_ID, userProfile.usrId, 2, "voto1");

            opinadorService.ValorarUsuario(VENDEDOR_ID, userProfile.usrId, 4, "voto2");
            opinadorService.ValorarUsuario(VENDEDOR_ID, userProfile.usrId, 3, "voto3");

            ValoracionBlock valoracionBlock = opinadorService.FindValoracionesAndNoteByVendedor(VENDEDOR_ID, START_INDEX, COUNT);

            Assert.IsTrue(valoracionBlock.NumValoraciones == 3);
            Assert.IsTrue(valoracionBlock.AverageValoracion == 3);
            Assert.IsTrue(valoracionBlock.Valoraciones.Contains(v1));
        }