Esempio n. 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;
            }
        }
Esempio n. 3
0
        public void FindValoracionesByVendedorWithNonExistentVendedorIdTest()
        {
            UserProfile userProfile = CreateTestUserProfile();
            Valoracion  valoracion  = CreateTestValoracion(userProfile.usrId, 4);
            Valoracion  valoracion1 = CreateTestValoracion(userProfile.usrId, 3);

            ValoracionBlock valoracionesBlock = opinadorService.FindValoracionesAndNoteByVendedor(NON_EXISTENT_VENDEDOR_ID, START_INDEX, COUNT);

            Assert.IsTrue(valoracionesBlock.Valoraciones.Count == 0);
            Assert.IsFalse(valoracionesBlock.Valoraciones.Contains(valoracion));
            Assert.IsFalse(valoracionesBlock.Valoraciones.Contains(valoracion1));
        }
Esempio n. 4
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));
        }
Esempio n. 5
0
        /// <exception cref="InstanceNotFoundException">If no Valoracion exist for the given vendedor identifier</exception>
        public ValoracionBlock FindValoracionesAndNoteByVendedor(string vendedorId, int startIndex, int count)
        {
            List <Valoracion> valoraciones = ValoracionDao.FindByVendedorId(vendedorId, startIndex, count);
            int numberValoraciones         = ValoracionDao.GetNumberByVendedorId(vendedorId);

            if (ValoracionDao.GetNumberByVendedorId(vendedorId) == 0)
            {
                throw new InstanceNotFoundException(vendedorId, "Valoracion");
            }
            double          note            = ValoracionDao.GetValoracionMediaByVendedorId(vendedorId);
            ValoracionBlock valoracionBlock = new ValoracionBlock(valoraciones, numberValoraciones, note);

            return(valoracionBlock);
        }