/// <summary>
 /// Patch changes
 /// </summary>
 /// <param name="source"></param>
 /// <param name="target"></param>
 public static void Patch(this dataModel.Price source, dataModel.Price target)
 {
     if (target == null)
         throw new ArgumentNullException("target");
     var patchInjection = new PatchInjection<dataModel.Price>(x => x.ProductId, x => x.List,
                                                                    x => x.MinQuantity, x => x.Sale);
     target.InjectFrom(patchInjection, source);
 }
		/// <summary>
		/// Patch changes
		/// </summary>
		/// <param name="source"></param>
		/// <param name="target"></param>
		public static void Patch(this dataModel.PricelistAssignment source, dataModel.PricelistAssignment target)
		{
			if (target == null)
				throw new ArgumentNullException("target");
			var patchInjection = new PatchInjection<dataModel.PricelistAssignment>(x => x.Name, x => x.Description,
																						 x => x.StartDate, x => x.EndDate, x => x.CatalogId,
																						 x => x.PricelistId, x => x.Priority, x => x.ConditionExpression);
			target.InjectFrom(patchInjection, source);
		}
		/// <summary>
		/// Patch changes
		/// </summary>
		/// <param name="source"></param>
		/// <param name="target"></param>
		public static void Patch(this dataModel.Pricelist source, dataModel.Pricelist target)
		{
			if (target == null)
				throw new ArgumentNullException("target");
			var patchInjection = new PatchInjection<dataModel.Pricelist>(x => x.Name, x => x.Currency,
																		   x => x.Description);
			target.InjectFrom(patchInjection, source);
		
			if (!source.Prices.IsNullCollection())
			{
				source.Prices.Patch(target.Prices, (sourcePrice, targetPrice) => sourcePrice.Patch(targetPrice));
			}
		
		} 
		private void TryToCreateCatalogAssignment(dataModel.Price price, IPricingRepository repository)
		{
			//need create price list assignment to catalog if it not exist
			var product = _productService.GetById(price.ProductId, Domain.Catalog.Model.ItemResponseGroup.ItemInfo);
			if (!repository.PricelistAssignments.Where(x => x.PricelistId == price.PricelistId && x.CatalogId == product.CatalogId).Any())
			{
				var assignment = new coreModel.PricelistAssignment
				{
					CatalogId = product.CatalogId,
					Name = product.Catalog.Name + "-" + price.Pricelist.Name,
					PricelistId = price.Pricelist.Id
				};
				CreatePriceListAssignment(assignment);
			}
		}