public ActionResult GetUserImage(string tkn = "") { string filepath = ""; string ImagePath = string.Empty; if (!string.IsNullOrEmpty(tkn)) { if (tkn == "loggedinUser") { var currentUserId = GlobalUser.getGlobalUser().UserId; var user = _userBusiness.GetListWT(c => c.UserId == currentUserId).FirstOrDefault(); ImagePath = "~/ProfileImage/" + user.ProfileImage; } else { var user = _userBusiness.GetListWT(c => c.TokenKey == tkn).FirstOrDefault(); ImagePath = "~/ProfileImage/" + user.ProfileImage; } filepath = !System.IO.File.Exists(Server.MapPath(ImagePath)) ? Server.MapPath("~/Content/Admin/Images/icon-user-default.png") : Server.MapPath(ImagePath); } else { filepath = Server.MapPath("~/Content/Admin/Images/icon-user-default.png"); } return(File(filepath, "image/jpg/gif/png")); }
// // 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 AddToCompareList(int productid, int size = 0, string attributes = "") { var currentUserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); var productSize = _productSizeBusiness.GetListWT(c => c.ProductId == productid).FirstOrDefault(); var defaultSize = productSize == null ? 0 : productSize.Id; if (size == 0) { size = defaultSize; } if (currentUserId > 0) { var count = _CompareListBusiness.GetListWT(c => c.UserId == currentUserId && c.ProductId == productid).Count(); if (count <= 0) { CompareList compareList = new CompareList(); compareList.ProductId = productid; compareList.UserId = currentUserId; _CompareListBusiness.Insert(compareList); _unitOfWork.SaveChanges(); } } else { CookieStore mycookie = new CookieStore(); var products = mycookie.GetCookie(Enumerator.CustomerAction.CompareList.ToString()); var value = string.Empty; if (string.IsNullOrEmpty(products)) { value = productid.ToString() + "~" + size.ToString() + "~" + attributes.ToString(); } else { if (!products.Split(',').Select(c => c.Split('~')[0]).Contains(productid.ToString())) { value = products + "," + productid.ToString() + "~" + size.ToString() + "~" + attributes.ToString(); } } var expireCookieTimeHr = Convert.ToInt32(ReadConfigData.GetAppSettingsValue("ExpireCookieTimeHr")); mycookie.SetCookie(Enumerator.CustomerAction.CompareList.ToString(), value, expireCookieTimeHr); } return(new EmptyResult()); }
public ActionResult ProductAddToCart(int productid, int quantity, int size = 0, string attributes = "") { var currentUserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); var productSize = _productSizeBusiness.GetListWT(c => c.ProductId == productid).FirstOrDefault(); var defaultSize = productSize == null ? 0 : productSize.Id; if (size == 0) { size = defaultSize; } if (currentUserId > 0) { var cartList = _AddToCartBusiness.GetListWT(c => c.UserId == currentUserId && c.ProductId == productid); AddToCart addToCart = new AddToCart(); addToCart.ProductId = productid; addToCart.UserId = currentUserId; addToCart.Quantity = quantity; addToCart.Size = size; addToCart.Attributes = attributes; if (cartList.Count() <= 0) { _AddToCartBusiness.Insert(addToCart); } else { addToCart.ID = cartList.FirstOrDefault().ID; _AddToCartBusiness.Update(addToCart); } _unitOfWork.SaveChanges(); } else { CookieStore mycookie = new CookieStore(); var products = mycookie.GetCookie(Enumerator.CustomerAction.AddToCart.ToString()); var newValue = productid.ToString() + "~" + quantity.ToString() + "~" + size.ToString() + "~" + attributes.ToString(); var value = mycookie.FormatCartCookieValue(products, newValue); var expireCookieTimeHr = Convert.ToInt32(ReadConfigData.GetAppSettingsValue("ExpireCookieTimeHr")); mycookie.SetCookie(Enumerator.CustomerAction.AddToCart.ToString(), value, expireCookieTimeHr); } return(new EmptyResult()); }
public void clearCart() { var currentUserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); if (currentUserId > 0) { var cartData = _AddToCartBusiness.GetList(c => c.UserId == currentUserId); foreach (var product in cartData) { _AddToCartBusiness.Delete(product); _unitOfWork.SaveChanges(); } } else { CookieStore mycookie = new CookieStore(); var expireCookieTimeHr = Convert.ToInt32(ReadConfigData.GetAppSettingsValue("ExpireCookieTimeHr")); mycookie.SetCookie(Enumerator.CustomerAction.AddToCart.ToString(), "", expireCookieTimeHr); } }
public ActionResult Review(ReviewViewModel reviewViewModel) { if (ModelState.IsValid) { try { var currentUser = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); var reveiwCount = _ReviewBusiness.GetListWT(c => c.UserId == currentUser && c.ProductId == reviewViewModel.ProductId).Count(); if (reveiwCount <= 0) { Mapper.CreateMap <ReviewViewModel, Review>(); var review = Mapper.Map <ReviewViewModel, Review>(reviewViewModel); review.CreatedDate = DateTime.Now; review.UserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); _ReviewBusiness.Insert(review); _unitOfWork.SaveChanges(); } } catch (Exception ex) { } } return(RedirectToAction("Index", new { productId = reviewViewModel.ProductId })); }
public ActionResult DeleteFromCompareList(int productid) { var currentUserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); if (currentUserId > 0) { var compareListProduct = _CompareListBusiness.GetList(c => c.UserId == currentUserId && c.ProductId == productid).FirstOrDefault(); if (compareListProduct != null) { _CompareListBusiness.Delete(compareListProduct); _unitOfWork.SaveChanges(); } } else { CookieStore mycookie = new CookieStore(); var products = mycookie.GetCookie(Enumerator.CustomerAction.CompareList.ToString()); var newCookieValueString = string.Empty; foreach (var prdId in products.Split(',')) { if (prdId.Split('~')[0] != productid.ToString()) { newCookieValueString = newCookieValueString + "," + prdId; } } var value = string.Empty; if (!string.IsNullOrEmpty(newCookieValueString)) { value = newCookieValueString.Substring(1); } var expireCookieTimeHr = Convert.ToInt32(ReadConfigData.GetAppSettingsValue("ExpireCookieTimeHr")); mycookie.SetCookie(Enumerator.CustomerAction.CompareList.ToString(), value, expireCookieTimeHr); } return(new EmptyResult()); }
public ActionResult DeleteFromCartList(int productid) { var currentUserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); if (currentUserId > 0) { var cartProduct = _AddToCartBusiness.GetList(c => c.UserId == currentUserId && c.ProductId == productid).FirstOrDefault(); if (cartProduct != null) { _AddToCartBusiness.Delete(cartProduct); _unitOfWork.SaveChanges(); } } else { CookieStore mycookie = new CookieStore(); var products = mycookie.GetCookie(Enumerator.CustomerAction.AddToCart.ToString()); var productId = productid.ToString(); var value = mycookie.FormatCartCookieValueAfterDelete(products, productId); var expireCookieTimeHr = Convert.ToInt32(ReadConfigData.GetAppSettingsValue("ExpireCookieTimeHr")); mycookie.SetCookie(Enumerator.CustomerAction.AddToCart.ToString(), value, expireCookieTimeHr); } return(new EmptyResult()); }
// // 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)); }