public ActionResult AddToCart(StoreItem storeItem)
        {
            try
            {
                var sg = new StoreGateway();
                var shoppingCartId = StoreGateway.GetShoppingCartId(HttpContext);
                StoreShoppingCart cart = null;

                if (shoppingCartId == null)
                {
                    cart = sg.CreateNewShoppingCart(storeItem.Store.MerchantId, RDN.Library.Classes.Account.User.GetUserId(), true, Request.UserHostAddress);
                    StoreGateway.SetShoppingCartSession(cart.ShoppingCartId, HttpContext);
                }
                else
                    cart = sg.GetShoppingCart(shoppingCartId.Value);

                int quantity = Convert.ToInt32(Request.Form["quantityToBuy"]);

                sg.AddItemToCart(cart.ShoppingCartId, storeItem.Store.MerchantId, storeItem.StoreItemId, quantity, storeItem.ItemSizeEnum, storeItem.ColorTempSelected);
                this.AddItemToCart(HttpContext.Session, quantity);
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/roller-derby-item/" + RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly(storeItem.Name) + "/" + storeItem.StoreItemId));

        }
        public ActionResult Review(StoreItem form)//RDN.Library.DataModels.Store.Review review
        {
            //http://localhost:8847/product-review/tdp1medium/10/e6cab01ce0044bd6a5d31970a7fe8dc0
            ItemReview oReview = new ItemReview();
            var memId = RDN.Library.Classes.Account.User.GetMemberId();
            oReview.MemberId = memId;
            oReview.rate = form.ratings;
            oReview.StoreItemId = form.StoreItemId;
            oReview.title = form.ReviewTitle;
            oReview.comment = form.ReviewComment;
            oReview.InvoiceItemId = form.InvoiceItemId;
            oReview.ReviewId = form.ReviewId;

            bool execute = RDN.Library.Classes.Store.ItemReview.AddReview(oReview);
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.re));

        }
예제 #3
0
 public StoreItem GetStoreItem(int itemId, bool getReviews = false)
 {
     var item = new StoreItem();
     try
     {
         var mc = new ManagementContext();
         var storeItem = mc.StoreItems.Include("Photos").Include("Reviews").Where(x => x.StoreItemId == itemId).FirstOrDefault();
         if (storeItem == null)
             return item;
         item = DisplayStoreItem(storeItem, getReviews);
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return item;
 }
예제 #4
0
        public List<StoreItem> GetStoreItems(int categoryId)
        {
            var output = new List<StoreItem>();
            try
            {
                var mc = new ManagementContext();
                var items = mc.StoreItems.Where(x => x.Category.StoreItemCategoryId.Equals(categoryId));

                foreach (var dbitem in items)
                {
                    var item = new StoreItem();
                    item.CanPickUpLocally = dbitem.CanPickUpLocally;
                    item.Name = dbitem.Name;
                    item.Description = dbitem.Description;
                    item.StoreItemId = dbitem.StoreItemId;
                    item.ArticleNumber = dbitem.ArticleNumber;
                    item.CanRunOutOfStock = dbitem.CanRunOutOfStock;
                    item.Price = dbitem.Price;
                    item.QuantityInStock = dbitem.QuantityInStock;
                    item.Weight = dbitem.Weight;
                    item.IsPublished = dbitem.IsPublished;
                    item.ItemType = (StoreItemTypeEnum)Enum.Parse(typeof(StoreItemTypeEnum), dbitem.ItemTypeEnum.ToString());
                    if (item.ItemType == StoreItemTypeEnum.Shirt)
                    {
                        item.ItemSize = (StoreItemShirtSizesEnum)Enum.Parse(typeof(StoreItemShirtSizesEnum), dbitem.SizesEnum.ToString());
                        item.ItemSizeEnum = dbitem.SizesEnum;
                    }
                    output.Add(item);
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return output;
        }
예제 #5
0
 private static void DisplayStoreItemColors(DataModels.Store.StoreItem storeItem, StoreItem item)
 {
     try
     {
         foreach (var color in storeItem.Colors)
         {
             ColorDisplay d = DisplayStoreItemColor(color);
             item.ColorTempSelected += d.HexColor + ";";
             item.Colors.Add(d);
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
 }
예제 #6
0
        private static StoreItem DisplayStoreItem(DataModels.Store.StoreItem storeItem, bool getAllReviews = false)
        {
            try
            {
                var item = new Classes.StoreItem();
                item.CanPickUpLocally = storeItem.CanPickUpLocally;
                item.ArticleNumber = storeItem.ArticleNumber;
                item.CanRunOutOfStock = storeItem.CanRunOutOfStock;
                if (storeItem.Merchant.CurrencyRate == null)
                {
                    item.Currency = "USD";
                    item.CurrencyCost = 1;
                }
                else
                {
                    item.Currency = storeItem.Merchant.CurrencyRate.CurrencyAbbrName;
                    item.CurrencyCost = storeItem.Merchant.CurrencyRate.CurrencyExchangePerUSD;
                }
                if (getAllReviews)
                {
                    foreach (var b in storeItem.Reviews)
                    {
                        item.Reviews.Add(ItemReview.DisplayReviewList(b));
                    }
                }
                item.Description = storeItem.Description;
                item.Shipping = storeItem.ShippingCosts;
                item.ShippingAdditional = storeItem.ShippingCostsAdditional;
                item.Name = storeItem.Name;
                if (item.Name.Length > 21)
                    item.NameTrimmed = item.Name.Remove(21) + "...";
                else
                    item.NameTrimmed = item.Name;

                item.Price = storeItem.Price;
                item.QuantityInStock = storeItem.QuantityInStock;
                item.StoreItemId = storeItem.StoreItemId;
                item.Weight = storeItem.Weight;

                if (storeItem.LastModified > new DateTime(2013, 11, 23) || storeItem.Created > new DateTime(2013, 11, 23))
                {
                    item.NoteHtml = storeItem.Note;
                }
                else if (storeItem.Created < new DateTime(2013, 11, 23))
                {
                    RDN.Library.Util.MarkdownSharp.Markdown markdown = new RDN.Library.Util.MarkdownSharp.Markdown();
                    markdown.AutoHyperlink = true;
                    markdown.LinkEmails = true;
                    item.NoteHtml = HtmlSanitize.FilterHtmlToWhitelist(markdown.Transform(storeItem.Note)).Replace("</p>", "</p><br/>");
                }

                item.Note = storeItem.Note;
                item.IsPublished = storeItem.IsPublished;
                item.Store.MerchantId = storeItem.Merchant.MerchantId;
                item.AcceptsPayPal = storeItem.Merchant.AcceptPaymentsViaPaypal;
                item.AcceptsStripe = storeItem.Merchant.AcceptPaymentsViaStripe;
                item.Views = storeItem.Views.ToString("N0");

                if (storeItem.Category != null)
                {
                    item.Category.Name = storeItem.Category.Name;
                    item.Category.StoreItemCategoryId = storeItem.Category.StoreItemCategoryId;
                }
                item.Store.Name = storeItem.Merchant.ShopName;

                if (!String.IsNullOrEmpty(storeItem.Merchant.ShopName) && storeItem.Merchant.ShopName.Length > 15)
                    item.Store.NameTrimmed = storeItem.Merchant.ShopName.Remove(15) + "...";
                else
                    item.Store.NameTrimmed = storeItem.Merchant.ShopName;
                item.Store.Description = storeItem.Merchant.Description;
                item.Store.MerchantId = storeItem.Merchant.MerchantId;
                item.ItemType = (StoreItemTypeEnum)Enum.Parse(typeof(StoreItemTypeEnum), storeItem.ItemTypeEnum.ToString());
                if (item.ItemType == StoreItemTypeEnum.Shirt)
                {
                    item.ItemSize = (StoreItemShirtSizesEnum)Enum.Parse(typeof(StoreItemShirtSizesEnum), storeItem.SizesEnum.ToString());
                    item.ItemSizeEnum = storeItem.SizesEnum;
                }

                foreach (var photo in storeItem.Photos)
                {
                    PhotoItem p = new PhotoItem(photo.ItemPhotoId, photo.ImageUrl, photo.ImageUrlThumb, photo.IsPrimaryPhoto, photo.AlternativeText);
                    item.Photos.Add(p);
                }
                DisplayStoreItemColors(storeItem, item);

                return item;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return null;
        }