Exemplo n.º 1
0
		private void StoreRetailPrices(BulkPriceAddModel model)
		{
			var priceExtraResult = ParserService.ParseExtraPricesBulk(
						model.ManufacturerId,
						model.SupplierId,
						model.Date,
						model.AlloyType,
						model.RollType,
						model.PriceExtraCategoryId,
						model.Remove,
						model.Prices);

			if (priceExtraResult.Errors.Any())
			{
				throw HttpException(HttpStatusCode.BadRequest, priceExtraResult.Errors.Join("<br/>"));
			}

			foreach (var product in priceExtraResult.Products)
			{
				var productId = product.ProductId;
				if (productId == 0)
				{
					productId = ProductService.CreateProduct(
						product.ManufacturerId,
						product.RawMaterialId,
						product.Name,
						product.Thickness).ProductId;
				}

				var extra = product.PriceExtras.Single();
				var priceItem = extra.PriceItems.Single();

				ProductService.SetRetailPrice(productId, model.Date, model.Remove ? null : priceItem.Price);
			}
		}
Exemplo n.º 2
0
		private void StoreMaterialPrices(BulkPriceAddModel model)
		{
			var materialsResult = ParserService.ParseMaterialPricesBulk(
						model.ManufacturerId,
						model.SupplierId,
						model.Date,
						model.AlloyType,
						model.RollType,
						model.Remove,
						model.Prices);

			if (materialsResult.Errors.Any())
			{
				throw HttpException(HttpStatusCode.BadRequest, materialsResult.Errors.Join("<br/>"));
			}

			foreach (var material in materialsResult.Materials)
			{
				var materialId = material.RawMaterialId;

				var priceItem = material.PriceItems.Single();

				ProductService.SetMaterialPrice(materialId, model.ManufacturerId, model.Date, model.Remove ? null : priceItem.Price);
			}
		}