Beispiel #1
0
        public ActionResult OrderItemAjaxDelete([DataSourceRequest] DataSourceRequest request, OrderItem model)
        {
            if (!LS.isHaveID())
            {
                ModelState.AddModelError("General", "You don't have permissions to edit this element");
                return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
            }
            var item = _db.OrderItems.FirstOrDefault(x => x.ID == model.ID);

            if (item != null)
            {
                var order = _db.Orders.FirstOrDefault(x => x.ID == item.OrderID);
                if (order != null)
                {
                    //check user
                    if (order.UserID != LS.CurrentUser.ID)
                    {
                        ModelState.AddModelError("General", "You don't have permissions to edit this element");
                        return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
                    }
                    decimal newCardTotal = order.Total;

                    newCardTotal += -item.UnitPrice;

                    order.Total = newCardTotal;
                    _db.OrderItems.Remove(item);
                    _db.SaveChanges();

                    return(Json(new[] { item }.ToDataSourceResult(request, ModelState)));
                }
            }


            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
Beispiel #2
0
 public ActionResult KeepOld(bool keep)
 {
     if (!LS.isHaveID())
     {
         return(Json(new { result = "error", action = "login", message = "You must login first" }));
     }
     if (LS.CurrentHttpContext.Request.Cookies["SALcart"] != null)
     {
         //retrieve old cart
         var oldGuid = new Guid(LS.CurrentHttpContext.Request.Cookies["SALcart"].Value);
         if (keep)
         {
             ShoppingCartService.MigrateShoppingCart(oldGuid, LS.CurrentUser.ID);
         }
         else
         {
             //remove old
             var forRemove = _db.ShoppingCartItems.Where(x => x.UserID == oldGuid).ToList();
             _db.ShoppingCartItems.RemoveRange(forRemove);
             _db.SaveChanges();
         }
         LS.DeleteCookie("SALcart");
     }
     return(Json(new { result = "ok" }));
 }
Beispiel #3
0
        public ActionResult ProductShop_AjaxAutoComplete([DataSourceRequest] DataSourceRequest request
                                                         , int ShopID, string text)
        {
            if (!LS.isHaveID())
            {
                return(Content(""));
            }
            //custom
            var items = (from ps in _db.ProductShopMap
                         join p in _db.Products
                         on ps.ProductID equals p.ID
                         where ps.ShopID == ShopID &&
                         p.Name.Contains(text)
                         select new
            {
                Name = (p.Name
                        // +" ("+ps.Price+")"
                        ),
                ID = ps.ID
            }).AsQueryable();
            DataSourceResult result = items.ToDataSourceResult(request);

            return(Json(result));

            //redirect to generic auto ready action
            // var generic = new BaseGenericController<ProductShop>();
            // generic._db = this._db;
            //sreturn generic._AjaxAutoComplete(request, text);
        }
        /// <summary>
        /// return 0 if can`t add
        /// </summary>
        /// <param name="ShopID"></param>
        /// <param name="Rate"></param>
        /// <param name="UserID"></param>
        /// <returns>id of rate or 0 if cant add</returns>
        public static int AddShopRate(int ShopID, int Rate, Guid UserID = new Guid())
        {
            var rate = new ShopRate();

            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return(0);
            }
            if (LS.CurrentEntityContext.ShopRates.Any(x => x.ShopID == ShopID && x.UserID == UserID))
            {
                return(0);
            }
            rate.UserID = UserID;
            rate.Rate   = Rate;
            rate.ShopID = ShopID;

            LS.CurrentEntityContext.ShopRates.Add(rate);
            LS.CurrentEntityContext.SaveChanges();

            var shop = LS.CurrentEntityContext.Shops.FirstOrDefault(x => x.ID == ShopID);

            if (shop != null)
            {
                shop.Rate = (shop.Rate * shop.RateCount + Rate) / (shop.RateCount + 1);
                shop.RateCount++;
                LS.CurrentEntityContext.SaveChanges();
            }
            return(rate.ID);
        }
Beispiel #5
0
        public ActionResult ReOrder(int ID)
        {
            if (!LS.isHaveID())
            {
                return(Json(new
                {
                    result = "error",
                    message = new Dictionary <string, Dictionary <string, List <string> > >()
                    {
                        { "general", new Dictionary <string, List <string> >()
                          {
                              { "errors", new List <string>()
                        {
                            "Please log in"
                        } }
                          } }
                    }
                }));
            }
            var order = _db.Orders.FirstOrDefault(x => x.ID == ID && x.UserID == LS.CurrentUser.ID);

            if (order != null)
            {
                // add to cart
                var items = _db.OrderItems.Where(x => x.OrderID == order.ID).ToList();
                foreach (var oi in items)
                {
                    if (oi.Quantity > 0)
                    {
                        ShoppingCartService.AddToCart(order.UserID, new ShoppingCartItem()
                        {
                            ProductAttributeOptionID = oi.ProductAttributeOptionID,
                            ProductShopID            = oi.ProductShopID,
                            Quantity = oi.Quantity,
                            ShopID   = order.ShopID,
                        });
                    }
                }

                return(Json(new
                {
                    result = "ok",
                    url = Url.Action("Index", "ShoppingCart", new { ID = order.ShopID })
                }));
            }
            return(Json(new
            {
                result = "error",
                message = new Dictionary <string, Dictionary <string, List <string> > >()
                {
                    { "general", new Dictionary <string, List <string> >()
                      {
                          { "errors", new List <string>()
                        {
                            "order not found"
                        } }
                      } }
                }
            }));
        }
        public static void AddProductToFavorite(int ProductShopID, Guid UserID = new Guid())
        {
            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return;
            }
            var fav = LS.CurrentEntityContext.ProductFavorites.FirstOrDefault(x => x.ProductShopID == ProductShopID &&
                                                                              x.UserID == UserID);

            if (fav == null)
            {
                UserActivityService.InsertFavoriteProduct(UserID, ProductShopID, false
                                                          , HttpContext.Current.Request.RawUrl,
                                                          HttpContext.Current.Request.UrlReferrer != null ? HttpContext.Current.Request.UrlReferrer.OriginalString : null
                                                          , LS.GetUser_IP(HttpContext.Current.Request));

                fav = new ProductFavorite()
                {
                    CreateDate    = DateTime.Now,
                    ProductShopID = ProductShopID,
                    UserID        = UserID
                };
                LS.CurrentEntityContext.ProductFavorites.Add(fav);
                LS.CurrentEntityContext.SaveChanges();
            }
        }
Beispiel #7
0
        public ActionResult OrderAjax([DataSourceRequest] DataSourceRequest request)
        {
            if (!LS.isHaveID())
            {
                return(Json(new { }));
            }
            //kendo reset manual sort to default =(
            if (request.Sorts == null)
            {
                request.Sorts = new List <SortDescriptor>();
            }
            if (request.Sorts.Count == 0)
            {
                request.Sorts.Add(new SortDescriptor("OrderStatus",
                                                     System.ComponentModel.ListSortDirection.Ascending));
                request.Sorts.Add(new SortDescriptor("ID",
                                                     System.ComponentModel.ListSortDirection.Descending));
            }
            var items = _db.Orders.Where(x => x.UserID == LS.CurrentUser.ID && !x.RegularOrder);

            DataSourceResult result = items.ToDataSourceResult(request);

            foreach (var item in (IEnumerable <Order>)result.Data)
            {
                item.TotalStr           = ShoppingService.FormatPrice(item.Total);
                item.RegularIntervalStr = RP.T("Enums." + item.RegularInterval.ToString()).ToString();
                item.OrderStatusStr     = RP.T("Enums." + item.OrderStatus.ToString()).ToString();
            }
            return(Json(result));
        }
        public static CheckoutData GetCheckoutData(Guid UserID = new Guid())
        {
            if (LS.CurrentHttpContext != null && LS.CurrentHttpContext.Items["CheckoutData"] != null)
            {
                return(LS.CurrentHttpContext.Items["CheckoutData"] as CheckoutData);
            }
            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return(null);
            }
            var checkoutData = LS.CurrentEntityContext.CheckoutDatas.FirstOrDefault(x => x.UserID == UserID);

            if (checkoutData == null)
            {
                //add to db if not exists
                checkoutData = new CheckoutData()
                {
                    UserID   = LS.CurrentUser.ID,
                    ShipTime = DateTime.Now,
                };
                LS.CurrentEntityContext.CheckoutDatas.Add(checkoutData);
                LS.CurrentEntityContext.SaveChanges();
            }
            if (LS.CurrentHttpContext != null)
            {
                LS.CurrentHttpContext.Items["CheckoutData"] = checkoutData;
            }
            return(checkoutData);
        }
Beispiel #9
0
        // its can be from child action and ajax loaded
        public ActionResult FooterCart(int ID = 0, bool tableonly = false)
        {
            var model = new ShoppingCartOverviewModel();

            if (LS.isHaveID())
            {
                if (ID == 0)
                {
                    if (LS.CurrentHttpContext.Session["ShopID"] != null)
                    {
                        ID = (int)LS.CurrentHttpContext.Session["ShopID"];
                    }
                    else
                    {
                        ID = ShoppingCartService.GetFirstShopID();
                    }
                }
                model = _shoppingCartService.GetShoppingCartModel(ID, withship: true);

                //_db.ShoppingCartItems.Where(x => x.UserID == LS.CurrentUser.ID).ToList();
            }

            if (!string.IsNullOrEmpty(model.Shop.Theme))
            {
                this.HttpContext.Items["ShopTheme"] = model.Shop.Theme;
            }

            if (tableonly)
            {
                return(PartialView("_CartTable", model));
            }
            return(PartialView(model));
        }
Beispiel #10
0
        public ActionResult ChangeItem(int ID, decimal?Quantity, decimal?QuantityBit, bool?Delete, int?Attribute, int?qtype)
        {
            if (!LS.isHaveID())
            {
                return(Json(new { result = "error", action = "login", message = "You must login first", data = ID }));
            }

            var item = new ShoppingCartItem()
            {
                ID = ID
            };
            var addmodel = ShoppingCartService.AddToCart(LS.CurrentUser.ID, item, Quantity, QuantityBit, Delete, Attribute, qtype);

            if (addmodel.errors.Count > 0)
            {
                return(Json(new { result = "error", message = addmodel.errors.FirstOrDefault(), data = addmodel.item }));
            }
            bool withship = true;

            if (Request.UrlReferrer != null && Request.UrlReferrer.PathAndQuery.ToLower().Contains("shoppingcart"))
            {
                withship = true;
            }
            var model = _shoppingCartService.GetShoppingCartModel(addmodel.item.ShopID, loadattributes: false, withship: withship);

            var curCartItem = model.Items.FirstOrDefault(x => x.ID == ID); //GetShoppingCartItemByID(ID);

            if (curCartItem != null)
            {
                return(Json(new { result = "ok", data = curCartItem, cart = model }));
            }
            return(Json(new { result = "ok", data = addmodel.item, cart = model }));
        }
Beispiel #11
0
        private CheckoutData GetCheckoutData(Guid UserID = new Guid())
        {
            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return(null);
            }
            var checkoutData = _db.CheckoutDatas.FirstOrDefault(x => x.UserID == UserID);

            if (checkoutData == null)
            {
                //add to db if not exists
                checkoutData = new CheckoutData()
                {
                    UserID   = LS.CurrentUser.ID,
                    ShipTime = DateTime.Now,
                };
                _db.CheckoutDatas.Add(checkoutData);
                _db.SaveChanges();
            }
            return(checkoutData);
        }
Beispiel #12
0
        public ActionResult SaveOrder(Order model)
        {
            if (!LS.isHaveID())
            {
                return(Json(new
                {
                    result = "error",
                    message = new Dictionary <string, Dictionary <string, List <string> > >()
                    {
                        { "general", new Dictionary <string, List <string> >()
                          {
                              { "errors", new List <string>()
                        {
                            "Please log in"
                        } }
                          } }
                    }
                }));
            }

            var order = _db.Orders.FirstOrDefault(x => x.ID == model.ID && x.UserID == LS.CurrentUser.ID);

            if (order != null)
            {
                order.Active          = model.Active;
                order.ShipTime        = model.ShipTime;
                order.RegularInterval = model.RegularInterval;
                _db.SaveChanges();
                return(Json(new
                {
                    result = "error",
                    message = new Dictionary <string, Dictionary <string, List <string> > >()
                    {
                        { "general", new Dictionary <string, List <string> >()
                          {
                              { "errors", new List <string>()
                        {
                            "Saved"
                        } }
                          } }
                    }
                }));
            }
            return(Json(new
            {
                result = "error",
                message = new Dictionary <string, Dictionary <string, List <string> > >()
                {
                    { "general", new Dictionary <string, List <string> >()
                      {
                          { "errors", new List <string>()
                        {
                            "order not found"
                        } }
                      } }
                }
            }));
        }
Beispiel #13
0
 public ActionResult DiscountHistoryAjax([DataSourceRequest] DataSourceRequest request)
 {
     if (!LS.isHaveID())
     {
         return(Content(""));
     }
     //redirect to generic auto ready action
     return(new BaseGenericController <DiscountUsage>()._AjaxRead(request));
 }
Beispiel #14
0
 public ActionResult ClearCart(int ID)
 {
     if (!LS.isHaveID())
     {
         return(Json(new { result = "error", action = "login", message = "You must login first", data = ID }));
     }
     ShoppingCartService.ClearCart(LS.CurrentUser.ID, ID);
     return(Json(new { result = "ok", data = ID }));
 }
Beispiel #15
0
        public ActionResult _OrderNote(int OrderID, [DataSourceRequest] DataSourceRequest request)
        {
            if (!LS.isHaveID())
            {
                return(Json(new { }));
            }
            var items = _db.OrderNotes.AsNoTracking().Where(x => x.OrderID == OrderID);

            DataSourceResult result = items.ToDataSourceResult(request);

            return(Json(result));
        }
        public static bool IsCanVoteForProduct(int productID, Guid userID)
        {
            if (userID == Guid.Empty && LS.isHaveID())
            {
                userID = LS.CurrentUser.ID;
            }
            if (userID == Guid.Empty)
            {
                return(false);
            }

            return(!LS.CurrentEntityContext.ProductRates.Any(x => x.ProductID == productID && x.UserID == userID));
        }
        public static bool IsCanVoteForShop(int ShopID, Guid UserID)
        {
            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return(false);
            }

            return(!LS.CurrentEntityContext.ShopRates.Any(x => x.ShopID == ShopID && x.UserID == UserID));
        }
        public ActionResult AddToCartAjx(ShoppingCartItem item, decimal?OverrideQuantity, bool isMobile = false)
        {
            if (!LS.isHaveID())
            {
                return(Json(new { result = "error", action = "login", message = "You must login first", data = item }));
            }
            var addmodel = ShoppingCartService.AddToCart(LS.CurrentUser.ID, item, OverrideQuantity, isMobile: isMobile);

            if (addmodel.errors.Count > 0)
            {
                return(Json(new { result = "error", message = addmodel.errors.FirstOrDefault(), data = addmodel.item }));
            }
            return(Json(new { result = "ok", data = addmodel.item }));
        }
Beispiel #19
0
        public ActionResult DiscountHistory()
        {
            UserActivityService.InsertUserClick(LS.CurrentUser.ID,
                                                Request.RawUrl,
                                                Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : null
                                                , LS.GetUser_IP(Request));
            if (!LS.isHaveID())
            {
                return(Redirect("~/"));
            }
            var model = LS.CurrentUser;

            return(View(model));
        }
Beispiel #20
0
        public ActionResult Index()
        {
            UserActivityService.InsertUserClick(LS.CurrentUser.ID,
                                                Request.RawUrl,
                                                Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : null
                                                , LS.GetUser_IP(Request));

            if (!LS.isHaveID())
            {
                return(Redirect("~/Account/LogOn"));
            }
            var model = LS.CurrentUser;

            return(View("Orders", model));
        }
Beispiel #21
0
        public ActionResult AddressSave(string AddressMap, decimal Latitude, decimal Longitude)
        {
            if (!LS.isHaveID())
            {
                return(Json(new
                {
                    result = "error",
                    message = new Dictionary <string, Dictionary <string, List <string> > >()
                    {
                        { "general", new Dictionary <string, List <string> >()
                          {
                              { "errors", new List <string>()
                        {
                            "Please log in"
                        } }
                          } }
                    }
                }));
            }
            if (string.IsNullOrEmpty(AddressMap))
            {
                return(Json(new
                {
                    result = "error",
                    message = new Dictionary <string, Dictionary <string, List <string> > >()
                    {
                        { "AddressMap", new Dictionary <string, List <string> >()
                          {
                              { "errors", new List <string>()
                        {
                            "Address can`t be empty"
                        } }
                          } }
                    }
                }));
            }
            var user = _db.Users.FirstOrDefault(x => x.ID == LS.CurrentUser.ID);

            if (user != null)
            {
                user.AddressMap = AddressMap;
                user.Longitude  = Longitude;
                user.Latitude   = Latitude;
                _db.SaveChanges();
            }
            return(Json(new { result = "ok" }));
        }
Beispiel #22
0
        public ActionResult OrderItemAjaxRead([DataSourceRequest] DataSourceRequest request)
        {
            if (!LS.isHaveID())
            {
                return(Content(""));
            }
            //redirect to generic auto ready action
            return(new BaseGenericController <OrderItem>()._AjaxRead(request));
            //deprecated
            //var items = _db.OrderItems.AsQueryable();
            //var result = items.ToDataSourceResult(request);
            //var ProductShopsIDs = ((IEnumerable<OrderItem>)result.Data).Select(x => x.ProductShopID);
            //var ProductAttributesIDs = ((IEnumerable<OrderItem>)result.Data).Select(x => x.ProductAttributeOptionID);
            //var StatusesIDs = ((IEnumerable<OrderItem>)result.Data).Select(x => x.OrderItemStatusID);

            //return Json(result);
        }
Beispiel #23
0
 public ActionResult AddToCartAjx(ShoppingCartItem item)
 {
     if (item.ProductShopID < 1)
     {
         return(Json(new { result = "error", message = "Data issuse", data = item }));
     }
     if (!LS.isHaveID())
     {
         return(Json(new { result = "error", action = "login", message = "You must login first", data = item }));
     }
     if (item.Quantity < 1)
     {
         return(Json(new { result = "error", message = "Quantity can`t be less then 1", data = item }));
     }
     //check existing
     ShoppingCartService.AddToCart(LS.CurrentUser.ID, item);
     return(Json(new { result = "ok", data = item }));
 }
        public static int AddProductRate(int productID, int Rate, Guid UserID = new Guid())
        {
            var rate = new ProductRate();

            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return(0);
            }
            rate = LS.CurrentEntityContext.ProductRates.FirstOrDefault(x => x.ProductID == productID && x.UserID == UserID);
            if (rate != null)
            {
                var product = LS.CurrentEntityContext.Products.FirstOrDefault(x => x.ID == productID);
                if (product != null)
                {
                    product.Rate = (product.Rate * product.RateCount - rate.Rate + Rate) / (product.RateCount);
                    // pr.RateCount++;
                    rate.Rate = Rate;
                    LS.CurrentEntityContext.SaveChanges();
                }
                return(rate.ID);
            }
            rate           = new ProductRate();
            rate.UserID    = UserID;
            rate.Rate      = Rate;
            rate.ProductID = productID;

            LS.CurrentEntityContext.ProductRates.Add(rate);
            LS.CurrentEntityContext.SaveChanges();

            var pr = LS.CurrentEntityContext.Products.FirstOrDefault(x => x.ID == productID);

            if (pr != null)
            {
                pr.Rate = (pr.Rate * pr.RateCount + Rate) / (pr.RateCount + 1);
                pr.RateCount++;
                LS.CurrentEntityContext.SaveChanges();
            }
            return(rate.ID);
        }
        public static ShopComment AddShopComment(ShopComment commen, int ParentID = 0, Guid UserID = new Guid())
        {
            var c = new ShopComment();

            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            c.UserID     = UserID;
            c.ParentID   = ParentID;
            c.ShopID     = commen.ShopID;
            c.Text       = commen.Text;
            c.Title      = commen.Title;
            c.UserName   = commen.UserName;
            c.CreateTime = DateTime.Now;
            LS.CurrentEntityContext.ShopComments.Add(c);
            LS.CurrentEntityContext.SaveChanges();
            return(c);
        }
        public static ProductComment AddProductComment(ProductComment commen, int ParentID = 0, Guid UserID = new Guid())
        {
            var productComment = new ProductComment();

            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            productComment.UserID     = UserID;
            productComment.ParentID   = ParentID;
            productComment.ProductID  = commen.ProductID;
            productComment.Text       = commen.Text;
            productComment.Title      = commen.Title;
            productComment.UserName   = commen.UserName;
            productComment.CreateDate = DateTime.Now;

            LS.CurrentEntityContext.ProductComments.Add(productComment);
            LS.CurrentEntityContext.SaveChanges();
            return(productComment);
        }
Beispiel #27
0
        public ActionResult Index(int ID = 0)
        {
            if (!LS.isHaveID())
            {
                return(Redirect("~/"));
            }
            if (ID == 0)
            {
                ID = ShoppingCartService.GetFirstShopID();
                if (ID > 0)
                {
                    return(RedirectToAction("Index", new { ID = ID }));
                }
            }
            var model = _shoppingCartService.GetShoppingCartModel(ID, feutured: true, withship: true
                                                                  , checkQuantity: true, loadComments: true);

            if (model.Shop == null || !model.Shop.Active)
            {
                return(Redirect("~/"));
            }


            if (LS.CurrentHttpContext.Request.Cookies["SALcart"] != null)
            {
                //retrieve old cart
                var oldGuid = new Guid(LS.CurrentHttpContext.Request.Cookies["SALcart"].Value);

                var oldModel = _shoppingCartService.GetShoppingCartModel(ID, feutured: true, withship: true
                                                                         , checkQuantity: true, loadComments: true, UserID: oldGuid);

                model.NotAvaliableItems = oldModel.Items;
            }

            if (!string.IsNullOrEmpty(model.Shop.Theme))
            {
                this.HttpContext.Items["ShopTheme"] = model.Shop.Theme;
            }

            return(View(model));
        }
Beispiel #28
0
        public ActionResult OrderDetail(int ID)
        {
            UserActivityService.InsertUserClick(LS.CurrentUser.ID,
                                                Request.RawUrl,
                                                Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : null
                                                , LS.GetUser_IP(Request));
            if (!LS.isHaveID())
            {
                return(Redirect("~/"));
            }
            var order = _db.Orders.FirstOrDefault(x => x.ID == ID && x.UserID == LS.CurrentUser.ID);

            if (order == null)
            {
                TempData["MessageRed"] = "Order doesn`t exists";
                return(RedirectToAction("Index"));
            }
            order.User = LS.CurrentUser;
            // order.OrderStatus = _db.OrderStatuses.FirstOrDefault(x => x.ID == order.OrderStatusID);

            return(View(order));
        }
Beispiel #29
0
        public ActionResult Address()
        {
            UserActivityService.InsertUserClick(LS.CurrentUser.ID,
                                                Request.RawUrl,
                                                Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : null
                                                , LS.GetUser_IP(Request));
            if (!LS.isHaveID())
            {
                return(Redirect("~/"));
            }
            var model = LS.CurrentUser;

            if (string.IsNullOrEmpty(model.AddressMap))
            {
                var checkoutData = GetCheckoutData();
                if (checkoutData.Address != null)
                {
                    model.AddressMap = checkoutData.Address;
                }
            }
            return(View(model));
        }
        public static void RemoveProductFromFavorite(int ProductShopID, Guid UserID = new Guid())
        {
            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return;
            }
            var fav = LS.CurrentEntityContext.ProductFavorites.FirstOrDefault(x => x.ProductShopID == ProductShopID &&
                                                                              x.UserID == UserID);

            if (fav != null)
            {
                UserActivityService.InsertFavoriteProduct(UserID, ProductShopID, true
                                                          , HttpContext.Current.Request.RawUrl,
                                                          HttpContext.Current.Request.UrlReferrer != null ? HttpContext.Current.Request.UrlReferrer.OriginalString : null
                                                          , LS.GetUser_IP(HttpContext.Current.Request));

                LS.CurrentEntityContext.ProductFavorites.Remove(fav);
                LS.CurrentEntityContext.SaveChanges();
            }
        }