Ejemplo n.º 1
0
        public PartialViewResult TopTenProductsWithFaults()
        {
            List<Product> products = new ProductServ.WCFProductClient().GetProducts().ToList();

            List<ReportModel> pr = new List<ReportModel>();

            foreach (Product p in products)
            {
                int faultNum = new BAFuncServ.WCFBAFuncClient().GetFaultNum(p.ID);
                ReportModel rp = new ReportModel();
                rp.Name = p.Name;
                rp.Features = p.Features;
                rp.Img = p.Image;
                rp.Number_Faults = faultNum;

                pr.Add(rp);

            }

            List<ReportModel> prSorted = pr.OrderByDescending(x => x.Number_Faults).ToList();

            return PartialView("_TopTenProductsWithFaults",prSorted);
        }
        public JsonResult UpdateProductRating(string productID, int rating)
        {
            if (rating < 0)
            {
                rating = 0;
            }
            else if (rating > 5)
            {
                rating = 5;
            }
            Rating r =  new ProductServ.WCFProductClient().GetRating(new Guid(productID),@User.Identity.Name);

            if (r != null)
            {
                r.Rating1 = rating;
                new ProductServ.WCFProductClient().UpdateProductRating(r);
            }
            else
            {
                r = new Rating();
                r.ProductID = new Guid(productID);
                r.Username = @User.Identity.Name;
                r.Rating1 = rating;
                new ProductServ.WCFProductClient().AddProductRating(r);
            }
            return Json("Success");
        }
Ejemplo n.º 3
0
        public PartialViewResult TopProduct()
        {
            List<Product> products = new ProductServ.WCFProductClient().GetProducts().ToList();

            TopProductModel tp = new TopProductModel();

            foreach (Product p in products)
            {
                int qtyB = new BAFuncServ.WCFBAFuncClient().GetQty(p.ID);
                if (qtyB > tp.Quantity_Ordered)
                {
                    tp.Quantity_Ordered = qtyB;
                    tp.Name = p.Name;
                    tp.Img = p.Image;
                    tp.Features = p.Features;
                }
            }

            List<TopProductModel> tpL = new List<TopProductModel>();
            tpL.Add(tp);

            return PartialView("_TopProduct",tpL);
        }