public ActionResult LoadFeaturesTtems(int?page) { if (Request.QueryString["page"] != null) { page = Convert.ToInt32(Request.QueryString["page"]); } var productList = _productBusiness.GetListWT(); 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)), ImageList = (from il in imgList where (il.ProductId == c.ProductID) select new ImageViewModel { ProductId = c.ProductID, Images = "/ProductImage/" + il.Images }).ToList() }).ToList(); int currentPageIndex = page.HasValue ? page.Value - 1 : 0; return(PartialView("_FeaturesItems", vmProductList.ToPagedList(currentPageIndex, DefaultPageSize))); //return PartialView("_FeaturesItems", vmProductList); }
// // GET: /Cart/ public ActionResult Index() { var productList = _productBusiness.GetListWT(); var assignedProductList = new List <AddToCart>(); var currentUserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); if (currentUserId > 0) { assignedProductList = _AddToCartBusiness.GetListWT(c => c.UserId == currentUserId); } else { CookieStore mycookie = new CookieStore(); 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 imgList = _ImageBusiness.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, 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), quantity = ap.Quantity, 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)); }
public ActionResult DisplayImage(string tkn) { var product = _productBusiness.GetListWT(c => c.TokenKey == tkn).FirstOrDefault(); int productId = product.ProductID; var imgList = _imageBusiness.GetListWT(c => c.ProductId == productId); Mapper.CreateMap <Product, ProductViewModel>(); var vmProduct = Mapper.Map <Product, ProductViewModel>(product); vmProduct.ImageList = (from il in imgList where (il.ProductId == product.ProductID) select new ImageViewModel { ImageId = il.ImageId, ProductId = product.ProductID, Images = "/ProductImage/Thumbnails/" + il.Images }).ToList(); return(PartialView("_DisplayImage", vmProduct)); }
public ActionResult orderitemdetails(int orderId) { OrderViewModel vmorder = new OrderViewModel(); var order = _orderBusiness.GetListWT(c => c.OrderId == orderId).FirstOrDefault(); var orderedItem = _itemBusiness.GetListWT(c => c.OrderId == orderId); var productList = _productBusiness.GetListWT(); Mapper.CreateMap <OrderDetail, OrderViewModel>(); vmorder = Mapper.Map <OrderDetail, OrderViewModel>(order); //showing cartdata to checkout var imgList = _ImageBusiness.GetListWT(); var vmProductList = (from c in productList join oi in orderedItem on c.ProductID equals oi.ProductId select new ItemListViewModel { ProductID = c.ProductID, ProductCode = c.ProductCode, ProductName = oi.ProductName, TokenKey = c.TokenKey, ShortDescription = c.ShortDescription, Price = oi.Price ?? 0, quantity = oi.OrderQuantity, DiscountPercent = oi.DiscountPercent, DiscountedPrice = Math.Round(oi.Price ?? 0 - Decimal.Divide(oi.DiscountPercent ?? 0, 100) * oi.Price ?? 0), SizeId = oi.Size.Value, Size = _productBusiness.GetSizeName(c.ProductID, oi.Size.Value), AttributeId = oi.Attributes, Attributes = _productBusiness.GetAttributes(c.ProductID, oi.Attributes), ImageList = (from il in imgList where (il.ProductId == c.ProductID) select new ImageViewModel { ProductId = c.ProductID, Images = "/ProductImage/" + il.Images }).ToList() }).ToList(); vmorder.orderItems = vmProductList; return(View(vmorder)); }
// // GET: /CheckOut/ public ActionResult Index() { EcommerceContext db = new EcommerceContext(); string[] WorkingHour = null; if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday) { WorkingHour = db.Settings.AsNoTracking().ToList()[0].Sat.ToString().Split('-'); } else if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday) { WorkingHour = db.Settings.AsNoTracking().ToList()[0].Sun.ToString().Split('-'); } else if (DateTime.Now.DayOfWeek == DayOfWeek.Monday) { WorkingHour = db.Settings.AsNoTracking().ToList()[0].Mon.ToString().Split('-'); } else if (DateTime.Now.DayOfWeek == DayOfWeek.Tuesday) { WorkingHour = db.Settings.AsNoTracking().ToList()[0].Tue.ToString().Split('-'); } else if (DateTime.Now.DayOfWeek == DayOfWeek.Wednesday) { WorkingHour = db.Settings.AsNoTracking().ToList()[0].Wed.ToString().Split('-'); } else if (DateTime.Now.DayOfWeek == DayOfWeek.Thursday) { WorkingHour = db.Settings.AsNoTracking().ToList()[0].Thur.ToString().Split('-'); } else if (DateTime.Now.DayOfWeek == DayOfWeek.Friday) { WorkingHour = db.Settings.AsNoTracking().ToList()[0].Fri.ToString().Split('-'); } DateTime FromDateTime = DateTime.Parse(DateTime.Now.ToString("MM/dd/yyyy") + " " + WorkingHour[0]); DateTime ToDateTime = DateTime.Parse(DateTime.Now.ToString("MM/dd/yyyy") + " " + WorkingHour[1]); if (FromDateTime.ToString("tt").ToLower() == "pm" && ToDateTime.ToString("tt").ToLower() == "am") { ToDateTime = ToDateTime.AddDays(1); } double iWorkingHour = (ToDateTime - FromDateTime).TotalHours; double CurrentTotalHour = (DateTime.Now - FromDateTime).TotalHours; bool IsClosed = false; if ((CurrentTotalHour >= iWorkingHour) || (DateTime.Now < FromDateTime)) { IsClosed = true; } CheckOutViewModel chkOut = new CheckOutViewModel(); var assignedProductList = new List <AddToCart>(); var productList = _productBusiness.GetListWT(); var currentUserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); CookieStore mycookie = new CookieStore(); 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(); } else { //Can't place order if cart empty // display message here } //assignedProductList = _AddToCartBusiness.GetListWT(c => c.UserId == currentUserId); //showing cartdata to checkout var imgList = _ImageBusiness.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, ProductName = c.ProductName, TokenKey = c.TokenKey, ShortDescription = c.ShortDescription, Price = _productBusiness.GetSelectedPrice(c.ProductID, ap.Size.GetValueOrDefault(), ap.Attributes), DiscountPercent = c.DiscountPercent, DiscountedPrice = 0, //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.GetValueOrDefault()), AttributeId = ap.Attributes, Attributes = _productBusiness.GetAttributes(c.ProductID, ap.Attributes), quantity = ap.Quantity, ImageList = (from il in imgList where (il.ProductId == c.ProductID) select new ImageViewModel { ProductId = c.ProductID, Images = "/ProductImage/" + il.Images }).ToList() }).ToList(); chkOut.OrderList = vmProductList; _userBusiness = new UserBusiness(); Entities.Models.User CurrentUser = (Entities.Models.User)Session["CurrentUserInfo"]; var currentUser = _userBusiness.GetUserByemail(CurrentUser.Email); chkOut.FirstNameShopper = currentUser.FirstName; chkOut.LastNameShopper = currentUser.LastName; chkOut.EmailShopper = currentUser.Email; chkOut.IsBlocked = currentUser.IsBlocked; chkOut.IsStoreClosed = IsClosed; return(View(chkOut)); }
// // 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)); }
// // 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); }