public ActionResult UploadItemPictures(StoreItemDisplayModel display)
        {
            try
            {
                foreach (string pictureFile in Request.Files)
                {
                    HttpPostedFileBase file = Request.Files[pictureFile];
                    if (file.ContentLength > 0)
                    {
                        StoreGateway sg = new StoreGateway();
                        sg.AddStoreItemPhoto(display.StoreItemId, file.InputStream, file.FileName);
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/store/item/edit/" + display.StoreItemId + "/" + display.PrivateManagerId.ToString().Replace("-", "") + "/" + display.MerchantId.ToString().Replace("-", "")));

        }
        public ActionResult StoreNewItem(StoreItemDisplayModel storeItem)
        {
            var sg = new StoreGateway();
            try
            {
                StoreItemDisplay display = new StoreItemDisplay();
                display.CanPickUpLocally = storeItem.CanPickUpLocally;
                display.ArticleNumber = storeItem.ArticleNumber;
                display.CanRunOutOfStock = storeItem.CanRunOutOfStock;
                display.Currency = storeItem.Currency;
                display.Description = storeItem.Description;
                display.InternalId = storeItem.InternalId;
                display.Note = storeItem.HtmlNote;
                display.Price = storeItem.Price;
                display.PrivateManagerId = storeItem.PrivateManagerId;
                display.QuantityInStock = storeItem.QuantityInStock;
                display.StoreItemId = storeItem.StoreItemId;
                display.Merchant.Name = storeItem.StoreName;
                display.Weight = storeItem.Weight;
                display.MerchantId = storeItem.MerchantId;
                display.Name = storeItem.Name;
                display.Shipping = storeItem.Shipping;
                display.HasExtraLarge = storeItem.HasExtraLarge;
                display.HasExtraSmall = storeItem.HasExtraSmall;
                display.HasLarge = storeItem.HasLarge;
                display.HasMedium = storeItem.HasMedium;
                display.HasSmall = storeItem.HasSmall;
                display.HasXXLarge = storeItem.HasXXLarge;
                display.ItemTypeEnum = storeItem.ItemTypeEnum;
                display.ItemType = storeItem.ItemType;
                display.ColorTempSelected = storeItem.ColorsSelected;

                display = sg.CreateNewStoreItem(display);
                if (display.StoreItemId > 0)
                    return Redirect(Url.Content("~/store/item/edit/" + display.StoreItemId + "/" + display.PrivateManagerId.ToString().Replace("-", "") + "/" + display.MerchantId.ToString().Replace("-", "")));

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            //if the item didn't actually get created.
            var store = sg.GetStoreForManager(storeItem.MerchantId, storeItem.PrivateManagerId, false);
            storeItem.InternalId = store.InternalReference;
            storeItem.MerchantId = store.MerchantId;
            storeItem.PrivateManagerId = store.PrivateManagerId;
            return View(storeItem);
        }
 public ActionResult StoreNewItem(Guid privId, Guid storeId)
 {
     StoreItemDisplayModel storeItem = new StoreItemDisplayModel();
     try
     {
         var sg = new StoreGateway();
         var store = sg.GetStoreForManager(storeId, privId, false);
         storeItem.InternalId = store.InternalReference;
         storeItem.MerchantId = store.MerchantId;
         storeItem.Currency = store.Currency;
         storeItem.PrivateManagerId = store.PrivateManagerId;
         StoreItemTypeEnum[] notInList = { StoreItemTypeEnum.None };
         storeItem.ItemTypeSelectList = StoreItemTypeEnum.Item.ToSelectList(notInList);
         var colors = ColorDisplayFactory.GetColors();
         storeItem.ColorList = new SelectList(colors, "HexColor", "NameOfColor");
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return View(storeItem);
 }
        public ActionResult StoreEditItem(int itemId, Guid privId, Guid storeId)
        {
            StoreItemDisplayModel model = new StoreItemDisplayModel();
            try
            {
                var sg = new StoreGateway();
                var store = sg.GetStoreItemManager(storeId, privId, itemId);
                model.ArticleNumber = store.ArticleNumber;
                model.CanRunOutOfStock = store.CanRunOutOfStock;
                model.CanPickUpLocally = store.CanPickUpLocally;
                model.Currency = store.Currency;
                model.Description = store.Description;
                model.HtmlNote = store.Note;
                model.InternalId = store.InternalId;
                model.MerchantId = store.MerchantId;
                model.Name = store.Name;
                model.Price = store.Price;
                model.Shipping = store.Shipping;
                model.ShippingAdditional = store.ShippingAdditional;
                model.PrivateManagerId = store.PrivateManagerId;
                model.QuantityInStock = store.QuantityInStock;
                model.StoreItemId = store.StoreItemId;
                model.StoreName = store.Merchant.Name;
                model.Weight = store.Weight;
                model.Photos = store.Photos;
                model.IsPublished = store.IsPublished;
                model.ItemSizeEnum = store.ItemSizeEnum;
                model.ItemTypeEnum = store.ItemTypeEnum;
                model.ItemType = store.ItemType;
                model.ItemSize = store.ItemSize;
                model.ColorsSelected = store.ColorTempSelected;
                model.Colors = store.Colors;
                store.ColorTempSelected = String.Empty;
                StoreItemTypeEnum[] notInList = { StoreItemTypeEnum.None };
                model.ItemTypeSelectList = store.ItemType.ToSelectList(notInList);
                var colors = ColorDisplayFactory.GetColors();
                model.ColorList = new SelectList(colors, "HexColor", "NameOfColor");

                if (model.ItemType == StoreItemTypeEnum.Shirt)
                {
                    Dictionary<String, Int32> sizes = new Dictionary<string, int>();
                    if (model.ItemSize.HasFlag(StoreItemShirtSizesEnum.Large))
                    {
                        sizes.Add(RDN.Portable.Util.Enums.EnumExt.ToFreindlyName(StoreItemShirtSizesEnum.Large), Convert.ToInt32(StoreItemShirtSizesEnum.Large));
                        model.HasLarge = true;
                    }
                    if (model.ItemSize.HasFlag(StoreItemShirtSizesEnum.Medium))
                    {
                        sizes.Add(RDN.Portable.Util.Enums.EnumExt.ToFreindlyName(StoreItemShirtSizesEnum.Medium), Convert.ToInt32(StoreItemShirtSizesEnum.Medium));
                        model.HasMedium = true;
                    }
                    if (model.ItemSize.HasFlag(StoreItemShirtSizesEnum.Small))
                    {
                        sizes.Add(RDN.Portable.Util.Enums.EnumExt.ToFreindlyName(StoreItemShirtSizesEnum.Small), Convert.ToInt32(StoreItemShirtSizesEnum.Small));
                        model.HasSmall = true;
                    }
                    if (model.ItemSize.HasFlag(StoreItemShirtSizesEnum.X_Large))
                    {
                        sizes.Add(RDN.Portable.Util.Enums.EnumExt.ToFreindlyName(StoreItemShirtSizesEnum.X_Large), Convert.ToInt32(StoreItemShirtSizesEnum.X_Large));
                        model.HasExtraLarge = true;
                    }
                    if (model.ItemSize.HasFlag(StoreItemShirtSizesEnum.X_Small))
                    {
                        sizes.Add(RDN.Portable.Util.Enums.EnumExt.ToFreindlyName(StoreItemShirtSizesEnum.X_Small), Convert.ToInt32(StoreItemShirtSizesEnum.X_Small));
                        model.HasExtraSmall = true;
                    }
                    if (model.ItemSize.HasFlag(StoreItemShirtSizesEnum.XX_Large))
                    {
                        sizes.Add(RDN.Portable.Util.Enums.EnumExt.ToFreindlyName(StoreItemShirtSizesEnum.XX_Large), Convert.ToInt32(StoreItemShirtSizesEnum.XX_Large));
                        model.HasXXLarge = true;
                    }

                    model.ItemSizes = new SelectList(sizes);
                }

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return View(model);
        }