public void Can_save_and_load_storeMapping()
        {
            var storeMapping = new StoreMapping
            {
                EntityId = 1,
                EntityName = "EntityName 1",
                Store = GetTestStore(),
            };

            var fromDb = SaveAndLoadEntity(storeMapping);
            fromDb.ShouldNotBeNull();
            fromDb.EntityId.ShouldEqual(1);
            fromDb.EntityName.ShouldEqual("EntityName 1");
            fromDb.Store.ShouldNotBeNull();
        }
        public void Can_save_and_load_urlRecord()
        {
            var storeMapping = new StoreMapping
            {
                EntityId = 1,
                EntityName = "EntityName 1",
                StoreId = 2,
            };

            var fromDb = SaveAndLoadEntity(storeMapping);
            fromDb.ShouldNotBeNull();
            fromDb.EntityId.ShouldEqual(1);
            fromDb.EntityName.ShouldEqual("EntityName 1");
            fromDb.StoreId.ShouldEqual(2);
        }
        public ActionResult AddProductToStore(ProducttModel model)
        {
            if (model.AddToMyStore)
            {
                var product = _productService.GetProductById(model.Id);
                product.LimitedToStores = true;
                _productService.UpdateProduct(product);
                
                var storeMapping = new StoreMapping
                {
                    EntityId = model.Id,
                    EntityName = "Product",
                    StoreId = _workContext.CurrentVendor.getStore().Id
                };
                _storeMappingService.InsertStoreMapping(storeMapping);
            }
            else
            {
                _storeMappingService.DeleteStoreMapping(
                    _storeMappingService.GetStoreMappings<Product>(
                        _productService.GetProductById(model.Id))
                        .SingleOrDefault(sm => sm.StoreId == _workContext.CurrentVendor.getStore().Id));
            }

            return new NullJsonResult();
        }