예제 #1
0
        public JsonResult GetBrands(string sidx, string sord, int page, int rows, string colName, string colValue)  //Gets the todo Lists.
        {
            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize  = rows;

            var brandList    = _brandBusiness.GetListWT();
            var categoryList = _categoryBusiness.GetListWT();
            List <BrandViewModel> brandViewModelList = new List <BrandViewModel>();

            var records = (from p in brandList
                           join c in categoryList on p.CategoryId equals c.CategoryId
                           select new BrandViewModel
            {
                TokenKey = p.TokenKey,
                BrandName = p.BrandName,
                CategoryName = c.CategoryName
            }).AsQueryable();

            //applying filter
            if (!string.IsNullOrEmpty(colName) && !string.IsNullOrEmpty(colValue))
            {
                records = records.Where(c => c.GetType().GetProperty(colName).GetValue(c, null).ToString().ToLower().Contains(colValue.ToLower()));
            }

            int totalRecords = records.Count();
            var totalPages   = (int)Math.Ceiling((float)totalRecords / (float)rows);

            if (!string.IsNullOrEmpty(sidx) && !string.IsNullOrEmpty(sord))
            {
                if (sord.Trim().ToLower() == "asc")
                {
                    records = SortHelper.OrderBy(records, sidx);
                }
                else
                {
                    records = SortHelper.OrderByDescending(records, sidx);
                }
            }

            //applying paging
            records = records.Skip(pageIndex * pageSize).Take(pageSize);

            var jsonData = new
            {
                total = totalPages,
                page,
                records = totalRecords,
                rows    = records
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult Create()
        {
            ProductViewModel productViewModel = new ProductViewModel();
            var categoryList    = _categoryBusiness.GetListWT();
            var subcategoryList = _subCategoryBusiness.GetListWT();

            productViewModel.CategoryList = categoryList.Select(x => new SelectListItem
            {
                Text  = x.CategoryName.ToString(),
                Value = x.CategoryId.ToString()
            }).ToList();
            productViewModel.AvailabilityList = Commom.GlobalMethods.GlobalMethods.GetAvailabilityList();
            return(View(productViewModel));
        }
예제 #3
0
        //
        // GET: /Cart/

        public ActionResult Index()
        {
            var productList = _productBusiness.GetListWT();

            var assignedProductList = new List <WishList>();
            var currentUserId       = Convert.ToInt32(GlobalUser.getGlobalUser().UserId);

            if (currentUserId > 0)
            {
                assignedProductList = _WishListBusiness.GetListWT(c => c.UserId == currentUserId);
            }
            else
            {
                CookieStore mycookie = new CookieStore();
                var         products = mycookie.GetCookie(Enumerator.CustomerAction.WishList.ToString());
                if (!string.IsNullOrEmpty(products))
                {
                    assignedProductList = (from p in products.Split(',')
                                           select new WishList
                    {
                        ProductId = Convert.ToInt32(p.Split('~')[0]),
                        Size = Convert.ToInt32(p.Split('~')[1]),
                        Attributes = p.Split('~')[2]
                    }).ToList();
                }
            }

            var imgList       = _ImageBusiness.GetListWT();
            var categoryList  = _CategoryBusiness.GetListWT();
            var vmProductList = (from c in productList
                                 join ap in assignedProductList
                                 on c.ProductID equals ap.ProductId
                                 select new CartWishlistViewModel
            {
                ProductID = c.ProductID,
                ProductCode = c.ProductCode,
                CategoryName = categoryList.Where(cat => cat.CategoryId == c.CategoryId).FirstOrDefault().CategoryName,
                ProductName = c.ProductName,
                TokenKey = c.TokenKey,
                ShortDescription = c.ShortDescription,
                Price = _productBusiness.GetSelectedPrice(c.ProductID, ap.Size.Value, ap.Attributes),
                DiscountPercent = c.DiscountPercent,
                DiscountedPrice = Math.Round(_productBusiness.GetSelectedPrice(c.ProductID, ap.Size.Value, ap.Attributes) - Decimal.Divide(c.DiscountPercent ?? 0, 100) * _productBusiness.GetSelectedPrice(c.ProductID, ap.Size.Value, ap.Attributes)),
                SizeId = ap.Size.Value,
                Size = _productBusiness.GetSizeName(c.ProductID, ap.Size.Value),
                AttributeId = ap.Attributes,
                Attributes = _productBusiness.GetAttributes(c.ProductID, ap.Attributes),
                ImageList = (from il in imgList
                             where (il.ProductId == c.ProductID)
                             select new ImageViewModel
                {
                    ProductId = c.ProductID,
                    Images = "/ProductImage/" + il.Images
                }).ToList()
            }).ToList();

            return(View(vmProductList));
        }
예제 #4
0
        public ActionResult LoadLeftSideBarHome()
        {
            var categoryList = _categoryBusiness.GetListWT();

            var subCategoryList = _subCategoryBusiness.GetListWT();

            Mapper.CreateMap <SubCategory, SubCategoryViewModel>();
            var vmSubCategoryList = Mapper.Map <List <SubCategory>, List <SubCategoryViewModel> >(subCategoryList);

            var vmCategoryList = (from c in categoryList
                                  select new CategoryViewModel
            {
                CategoryId = c.CategoryId,
                TokenKey = c.TokenKey,
                CategoryName = c.CategoryName,
                subCategoryList = vmSubCategoryList.Where(sc => sc.CategoryId == c.CategoryId).ToList()
            }).ToList();

            LeftSideBarViewModel leftSideBarViewModel = new LeftSideBarViewModel();

            leftSideBarViewModel.categoryList = vmCategoryList;
            return(PartialView("_LoadLeftSideBarHome", leftSideBarViewModel));
        }
예제 #5
0
        //
        // GET: /ProductDetail/

        public ActionResult Index(int productId)
        {
            var product = _productBusiness.GetListWT(c => c.ProductID == productId).FirstOrDefault();
            var imgList = _ImageBusiness.GetListWT(c => c.ProductId == productId);

            Mapper.CreateMap <Product, ProductViewModel>();
            var vmProduct = Mapper.Map <Product, ProductViewModel>(product);

            CookieStore mycookie            = new CookieStore();
            var         assignedProductList = new List <AddToCart>();
            var         products            = mycookie.GetCookie(Enumerator.CustomerAction.AddToCart.ToString());

            if (!string.IsNullOrEmpty(products))
            {
                assignedProductList = (from p in products.Split(',')
                                       select new AddToCart
                {
                    ProductId = Convert.ToInt32(p.Split('~')[0]),
                    Quantity = Convert.ToInt32(p.Split('~')[1]),
                    Size = Convert.ToInt32(p.Split('~')[2]),
                    Attributes = p.Split('~')[3]
                }).ToList();
            }

            var productAssigned = assignedProductList.Where(c => c.ProductId == productId).FirstOrDefault();

            if (productAssigned != null)
            {
                vmProduct.SizeId          = productAssigned.Size.Value;
                vmProduct.Attributes      = productAssigned.Attributes;
                vmProduct.Price           = _productBusiness.GetSelectedPrice(productId, productAssigned.Size.Value, productAssigned.Attributes) * productAssigned.Quantity;
                vmProduct.ProductQuantity = productAssigned.Quantity;
            }
            else
            {
                var defaultSize = _productSizeBusiness.GetListWT(c => c.ProductId == productId).FirstOrDefault();
                vmProduct.SizeId          = defaultSize == null ? 0 : defaultSize.Id;
                vmProduct.Attributes      = "";
                vmProduct.Price           = _productBusiness.GetDefaultPrice(productId);
                vmProduct.ProductQuantity = 1;
            }



            vmProduct.DiscountPercent = vmProduct.DiscountPercent ?? 0;
            vmProduct.DiscountedPrice = Math.Round(vmProduct.Price - Decimal.Divide(vmProduct.DiscountPercent ?? 0, 100) * vmProduct.Price);
            vmProduct.ImageList       = (from il in imgList
                                         where (il.ProductId == product.ProductID)
                                         select new ImageViewModel
            {
                ProductId = product.ProductID,
                Images = "/ProductImage/" + il.Images
            }).ToList();

            vmProduct.ProductSizeList = (from ps in _productSizeBusiness.GetListWT(c => c.ProductId == productId).ToList()
                                         select new ProductSizeViewModel
            {
                Id = ps.Id,
                ProductId = ps.ProductId,
                Price = ps.Price,
                Size = ps.Size
            }).ToList();
            vmProduct.ProductAttributeList = (from ps in _productAttributeBusiness.GetListWT(c => c.ProductId == productId).ToList()
                                              select new ProductAttributeViewModel
            {
                Id = ps.Id,
                ProductId = ps.ProductId,
                Price = ps.Price,
                Attributes = ps.Attributes
            }).ToList();



            var breadcrumb = new List <KeyValuePair <string, string> >();

            breadcrumb.Add(new KeyValuePair <string, string>("Home", "/Home/index"));
            var category = _CategoryBusiness.GetListWT(c => c.CategoryId == vmProduct.CategoryId).FirstOrDefault();

            if (category != null)
            {
                breadcrumb.Add(new KeyValuePair <string, string>(category.CategoryName, "/Product/index?categoryid=" + category.CategoryId));
            }
            var subcategory = _SubCategoryBusiness.GetListWT(c => c.SubCategoryId == vmProduct.SubCategoryId).FirstOrDefault();

            if (subcategory != null)
            {
                breadcrumb.Add(new KeyValuePair <string, string>(subcategory.SubCategoryName, "/Product/index?subcategoryid=" + subcategory.SubCategoryId));
            }
            breadcrumb.Add(new KeyValuePair <string, string>(vmProduct.ProductName, ""));
            ViewBag.BreadCrumb = breadcrumb.ToList();
            return(View(vmProduct));
        }
예제 #6
0
        //
        // GET: /Product/

        public ActionResult Index(int?page, int categoryid = 0, int subcategoryid = 0, string brand = "", string price = "", string color = "")
        {
            var breadcrumb = new List <KeyValuePair <string, string> >();

            breadcrumb.Add(new KeyValuePair <string, string>("Home", "/Home/index"));
            var productList = new List <Product>();

            if (categoryid != 0)
            {
                var category = _categoryBusiness.GetListWT(c => c.CategoryId == categoryid).FirstOrDefault();
                breadcrumb.Add(new KeyValuePair <string, string>(category.CategoryName, ""));
                productList = _productBusiness.GetListWT(c => c.CategoryId == categoryid);
            }
            if (subcategoryid != 0)
            {
                var subCategory = _subCategoryBusiness.GetListWT(c => c.SubCategoryId == subcategoryid).FirstOrDefault();
                var category    = _categoryBusiness.GetListWT(c => c.CategoryId == subCategory.CategoryId).FirstOrDefault();
                breadcrumb.Add(new KeyValuePair <string, string>(category.CategoryName, "/Product/index?categoryid=" + category.CategoryId));
                breadcrumb.Add(new KeyValuePair <string, string>(subCategory.SubCategoryName, ""));
                productList = _productBusiness.GetListWT(c => c.SubCategoryId == subcategoryid);
            }

            if (!string.IsNullOrEmpty(brand))
            {
                var brands = brand.Split(',');
                productList = productList.Where(c => brands.Contains(c.BrandId.ToString())).ToList();
            }

            //if (string.IsNullOrEmpty(brand))
            //{
            //    var brand = _brandBusiness.GetListWT(c => c.BrandId == brandid).FirstOrDefault();
            //    productList = _productBusiness.GetListWT(c => c.BrandId == brandid);
            //}

            if (!string.IsNullOrEmpty(price))
            {
                var pricerange = price.Split(',');
                var lowerLimit = Convert.ToDecimal(pricerange[0]);
                var upperLimit = Convert.ToDecimal(pricerange[1]);
                productList = productList.Where(c => _productBusiness.GetDefaultPrice(c.ProductID) >= lowerLimit && _productBusiness.GetDefaultPrice(c.ProductID) <= upperLimit).ToList();
            }

            var imgList       = _ImageBusiness.GetListWT();
            var vmProductList = (from c in productList
                                 select new ProductViewModel
            {
                ProductID = c.ProductID,
                ProductName = c.ProductName,
                TokenKey = c.TokenKey,
                ShortDescription = c.ShortDescription,
                Price = _productBusiness.GetDefaultPrice(c.ProductID),
                DiscountPercent = c.DiscountPercent,
                DiscountedPrice = Math.Round(_productBusiness.GetDefaultPrice(c.ProductID) - Decimal.Divide(c.DiscountPercent ?? 0, 100) * _productBusiness.GetDefaultPrice(c.ProductID)),
                Availability = c.Availability,
                ImageList = (from il in imgList
                             where (il.ProductId == c.ProductID)
                             select new ImageViewModel
                {
                    ProductId = c.ProductID,
                    Images = "/ProductImage/" + il.Images
                }).ToList()
            }).ToList();

            ViewBag.BreadCrumb = breadcrumb.ToList();

            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;

            return(View(vmProductList.ToPagedList(currentPageIndex, DefaultPageSize)));
            //return View(vmProductList);
        }