Example #1
0
        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());
        }
Example #2
0
        public virtual void DeleteStoreMapping(StoreMapping storeMapping)
        {
            Guard.NotNull(storeMapping, nameof(storeMapping));

            _storeMappingRepository.Delete(storeMapping);

            ClearCacheSegment(storeMapping.EntityName, storeMapping.EntityId);
        }
        public virtual void DeleteStoreMapping(StoreMapping storeMapping)
        {
            Guard.NotNull(storeMapping, nameof(storeMapping));

            _storeMappingRepository.Delete(storeMapping);

            _cacheManager.RemoveByPattern(STOREMAPPING_PATTERN_KEY);
        }
Example #4
0
        public void UpdateStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException("storeMapping");
            }

            _storeMappingRepository.Update(storeMapping);
        }
Example #5
0
        public void DeleteStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException("storeMapping");
            }

            _storeMappingRepository.Delete(storeMapping);
            //_unitOfWork.Commit();
        }
		/// <summary>
		/// Deletes a store mapping record
		/// </summary>
		/// <param name="storeMapping">Store mapping record</param>
		public virtual void DeleteStoreMapping(StoreMapping storeMapping)
		{
			if (storeMapping == null)
				throw new ArgumentNullException("storeMapping");

			_storeMappingRepository.Delete(storeMapping);

			//cache
			_cacheManager.RemoveByPattern(STOREMAPPING_PATTERN_KEY);
		}
Example #7
0
        protected async Task InsertStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException(nameof(storeMapping));
            }

            await _storeMappingRepository.InsertAsync(storeMapping);

            _cacheManager.RemoveByPattern(StoreDefaults.StoreMappingPatternCacheKey);
        }
Example #8
0
        public async Task DeleteStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException(nameof(storeMapping));
            }

            await _storeMappingRepository.DeleteAsync(storeMapping);

            _cacheManager.RemoveByPattern(StoreDefaults.StoreMappingPatternCacheKey);
        }
Example #9
0
        /// <summary>
        /// Inserts a store mapping record
        /// </summary>
        /// <param name="storeMapping">Store mapping</param>
        protected virtual void InsertStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException(nameof(storeMapping));
            }

            _storeMappingRepository.Insert(storeMapping);

            //event notification
            _eventPublisher.EntityInserted(storeMapping);
        }
Example #10
0
        /// <summary>
        /// Deletes a store mapping record
        /// </summary>
        /// <param name="storeMapping">Store mapping record</param>
        public virtual void DeleteStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException(nameof(storeMapping));
            }

            _storeMappingRepository.Delete(storeMapping);

            //event notification
            _eventPublisher.EntityDeleted(storeMapping);
        }
Example #11
0
        public void InsertStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new Exception("storeMapping");
            }

            _storeMappingRepository.Insert(storeMapping);

            _cacheManager.RemoveByPattern(STOREMAPPING_PATTERN_KEY);

            _eventPublisher.EntityInserted(storeMapping);
        }
Example #12
0
        public void DeleteStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentException("storeMapping");
            }

            _storeMappingRepository.Delete(storeMapping);

            _cacheManager.RemoveByPattern(STOREMAPPING_PATTERN_KEY);

            _eventPublisher.EntityDeleted(storeMapping);
        }
Example #13
0
        /// <summary>
        /// Deletes a store mapping record
        /// </summary>
        /// <param name="storeMapping">Store mapping record</param>
        public virtual void DeleteStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException(nameof(storeMapping));
            }

            _storeMappingRepository.Delete(storeMapping);

            //cache
            _cacheManager.RemoveByPattern(NopStoreDefaults.StoreMappingPatternCacheKey);

            //event notification
            _eventPublisher.EntityDeleted(storeMapping);
        }
        /// <summary>
        /// Inserts a store mapping record
        /// </summary>
        /// <param name="storeMapping">Store mapping</param>
        protected virtual void InsertStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException(nameof(storeMapping));
            }

            _storeMappingRepository.Insert(storeMapping);

            //cache
            _cacheManager.RemoveByPattern(GSStoreDefaults.StoreMappingPatternCacheKey);

            //event notification
            _eventPublisher.EntityInserted(storeMapping);
        }
        /// <summary>
        /// Inserts a store mapping record
        /// </summary>
        /// <param name="storeMapping">Store mapping</param>
        protected virtual void InsertStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException(nameof(storeMapping));
            }

            _storeMappingRepository.Insert(storeMapping);

            //cache
            _cacheManager.RemoveByPattern(STOREMAPPING_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityInserted(storeMapping);
        }
Example #16
0
        /// <summary>
        /// Updates the store mapping record
        /// </summary>
        /// <param name="storeMapping">Store mapping</param>
        public virtual void UpdateStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException("storeMapping");
            }

            _storeMappingRepository.Update(storeMapping);

            //cache
            _cacheManager.RemoveByPattern(STOREMAPPING_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityUpdated(storeMapping);
        }
        /// <summary>
        /// Deletes a store mapping record
        /// </summary>
        /// <param name="storeMapping">Store mapping record</param>
        public virtual void DeleteStoreMapping(StoreMapping storeMapping)
        {
            if (storeMapping == null)
            {
                throw new ArgumentNullException("storeMapping");
            }

            _storeMappingRepository.Delete(storeMapping);

            //cache
            _cacheManager.GetCache(CACHE_NAME_STOREMAPPING).Clear();

            //event notification
            //_eventPublisher.EntityDeleted(storeMapping);
        }
        public virtual void InsertStoreMapping(int entityId, string entityName, int storeId)
        {
            if (storeId == 0)
            {
                throw new ArgumentOutOfRangeException("storeId");
            }

            var storeMapping = new StoreMapping()
            {
                EntityId   = entityId,
                EntityName = entityName,
                StoreId    = storeId
            };

            InsertStoreMapping(storeMapping);
        }
        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);
        }
Example #21
0
        public void InsertStoreMapping <T>(T entity, int storeId) where T : BaseEntity, IStoreMappingSupported
        {
            if (entity == null)
            {
                throw new Exception("entity");
            }

            int    entityId     = entity.Id;
            string entityName   = typeof(T).Name;
            var    storeMapping = new StoreMapping()
            {
                EntityId   = entityId,
                EntityName = entityName,
                StoreId    = storeId
            };

            InsertStoreMapping(storeMapping);
        }
		/// <summary>
		/// Inserts a store mapping record
		/// </summary>
		/// <typeparam name="T">Type</typeparam>
		/// <param name="storeId">Store id</param>
		/// <param name="entity">Entity</param>
		public virtual void InsertStoreMapping<T>(T entity, int storeId) where T : BaseEntity, IStoreMappingSupported
		{
			if (entity == null)
				throw new ArgumentNullException("entity");

			if (storeId == 0)
				throw new ArgumentOutOfRangeException("storeId");

			int entityId = entity.Id;
			string entityName = typeof(T).Name;

			var storeMapping = new StoreMapping
			{
				EntityId = entityId,
				EntityName = entityName,
				StoreId = storeId
			};

			InsertStoreMapping(storeMapping);
		}
Example #23
0
        public virtual void InsertStoreMapping <T>(T entity, int storeId) where T : BaseEntity, IStoreMappingSupported
        {
            Guard.NotNull(entity, nameof(entity));

            if (storeId == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(storeId));
            }

            int    entityId   = entity.Id;
            string entityName = entity.GetEntityName();

            var storeMapping = new StoreMapping
            {
                EntityId   = entityId,
                EntityName = entityName,
                StoreId    = storeId
            };

            InsertStoreMapping(storeMapping);
        }
Example #24
0
        /// <summary>
        /// Inserts a store mapping record
        /// </summary>
        /// <param name="entityName">Type</param>
        /// <param name="storeId">Store id</param>
        /// <param name="entity">Entity</param>
        public void InsertStoreMapping(string entityName, dynamic entity, int storeId)
        {
            if (entity == "null")
            {
                throw new ArgumentNullException("entityId");
            }

            if (storeId == 0)
            {
                throw new ArgumentOutOfRangeException("storeId");
            }


            var storeMapping = new StoreMapping
            {
                EntityId   = entity.Id,
                EntityName = entityName,
                StoreId    = storeId
            };

            InsertStoreMapping(storeMapping);
        }
        /// <summary>
        /// Inserts a store mapping record
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <param name="storeId">Store id</param>
        /// <param name="entity">Entity</param>
        public virtual void InsertStoreMapping <T>(int id, string name, int storeId)
        {
            //if (entity == null)
            //    throw new ArgumentNullException("entity");

            if (storeId == 0)
            {
                throw new ArgumentOutOfRangeException("storeId");
            }

            int    entityId   = id;
            string entityName = name;

            var storeMapping = new StoreMapping
            {
                EntityId   = entityId,
                EntityName = entityName,
                StoreId    = storeId
            };

            InsertStoreMapping(storeMapping);
        }
Example #26
0
        /// <summary>
        /// Inserts a store mapping record
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <param name="storeId">Store id</param>
        /// <param name="entity">Entity</param>
        public virtual void InsertStoreMapping <T>(T entity, int storeId) where T : BaseEntity, IStoreMappingSupported
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (storeId == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(storeId));
            }

            var entityId   = entity.Id;
            var entityName = entity.GetUnproxiedEntityType().Name;

            var storeMapping = new StoreMapping
            {
                EntityId   = entityId,
                EntityName = entityName,
                StoreId    = storeId
            };

            InsertStoreMapping(storeMapping);
        }
        /// <summary>
        /// Inserts a store mapping record
        /// </summary>
        /// <typeparam name="TEntity">Type of entity that supports store mapping</typeparam>
        /// <param name="entity">Entity</param>
        /// <param name="storeId">Store id</param>
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task InsertStoreMappingAsync <TEntity>(TEntity entity, int storeId) where TEntity : BaseEntity, IStoreMappingSupported
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (storeId == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(storeId));
            }

            var entityId   = entity.Id;
            var entityName = entity.GetType().Name;

            var storeMapping = new StoreMapping
            {
                EntityId   = entityId,
                EntityName = entityName,
                StoreId    = storeId
            };

            await InsertStoreMappingAsync(storeMapping);
        }
Example #28
0
 /// <summary>
 /// Deletes a store mapping record
 /// </summary>
 /// <param name="storeMapping">Store mapping record</param>
 public void DeleteStoreMapping([FromBody] StoreMapping storeMapping)
 {
     _storeMappingService.DeleteStoreMapping(storeMapping);
 }
 /// <summary>
 /// Deletes a store mapping record
 /// </summary>
 /// <param name="storeMapping">Store mapping record</param>
 /// <returns>A task that represents the asynchronous operation</returns>
 public virtual async Task DeleteStoreMappingAsync(StoreMapping storeMapping)
 {
     await _storeMappingRepository.DeleteAsync(storeMapping);
 }
 /// <summary>
 /// Inserts a store mapping record
 /// </summary>
 /// <param name="storeMapping">Store mapping</param>
 /// <returns>A task that represents the asynchronous operation</returns>
 protected virtual async Task InsertStoreMappingAsync(StoreMapping storeMapping)
 {
     await _storeMappingRepository.InsertAsync(storeMapping);
 }