Exemplo n.º 1
0
        /// <summary>
        /// Product Updated
        /// </summary>
        /// <param name="transaction"></param>
        private async Task ProductUpdated(TransactionQueueInbound transaction)
        {
            ProductUpdatePayload payload = JsonConvert.DeserializeObject <ProductUpdatePayload>(transaction.Payload);

            int productMasterId = payload.ProductId;

            Product product = await _purchaseOrderManagementDataService.GetProductInformationByProductMasterForUpdate(productMasterId);

            if (product != null)
            {
                product.ProductNumber = payload.ProductNumber;
                product.Description   = payload.Description;
                product.UnitPrice     = payload.UnitPrice;

                await _purchaseOrderManagementDataService.UpdateProduct(product);
            }
            else
            {
                product                 = new Product();
                product.AccountId       = payload.AccountId;
                product.ProductNumber   = payload.ProductNumber;
                product.ProductMasterId = payload.ProductId;
                product.Description     = payload.Description;
                product.UnitPrice       = payload.UnitPrice;

                await _purchaseOrderManagementDataService.CreateProduct(product);
            }

            await LogSuccessfullyProcessed(transaction);
        }