public Task StartAsync(CancellationToken cancellationToken) { _BusListenerConnectionString = Configuration["ListenetConnectionString"]; using (var scope = _serviceScopeFactory.CreateScope()) { _productService = scope.ServiceProvider.GetService <IProductService>(); _updateProduct = scope.ServiceProvider.GetService <IUpdateProduct>(); _logger.LogDebug($"BusListener starting; Registering message handler."); _subscriptionClient = new SubscriptionClient(_BusListenerConnectionString, "sale-send", "Sale-Message"); var messageHandlerOptions = new MessageHandlerOptions(e => { ProcessError(e.Exception); return(Task.CompletedTask); }) { MaxConcurrentCalls = 1, AutoComplete = false }; _subscriptionClient.RegisterMessageHandler(ProcessMessageAsync, messageHandlerOptions); return(Task.CompletedTask); } }
public ProductController(ICreateProduct createProduct, IGetProduct getProduct, IUpdateProduct updateProduct, IRemoveProduct removeProduct) { this.createProduct = createProduct; this.getProduct = getProduct; this.updateProduct = updateProduct; this.removeProduct = removeProduct; }
public ProductService(IAddProduct addProduct = null, IGetProducts getProducts = null, IUpdateProduct updateProduct = null, IDeleteProduct deleteProduct = null) { _addProduct = addProduct; _getProducts = getProducts; _updateProduct = updateProduct; _deleteProduct = deleteProduct; }
public SaleService( IGenericRepository <Sale> repository, IMessageHandler messageHandler, IUpdateProduct updateProduct, IProductRepository productRepository) : base(repository) { _repository = repository; _messageHandler = messageHandler; _updateProduct = updateProduct; _productRepository = productRepository; }
public ProductController(IGetProduct getProduct, ICreateProduct createProduct, IUpdateProduct updateProduct, IRemoveProduct removeProduct, IValidateProductPrice validateProductPrice, IConfirmProductPrice confirmProductPrice) { this.getProduct = getProduct; this.createProduct = createProduct; this.updateProduct = updateProduct; this.removeProduct = removeProduct; this.validateProductPrice = validateProductPrice; this.confirmProductPrice = confirmProductPrice; }
public Task ProcessMessageAsync(Message message, CancellationToken arg2) { var receivedMessage = message.Body.ParseJson <SaleInputMessage>(); var sale = new Sale(receivedMessage.SaleId, receivedMessage.ProductId, receivedMessage.Quantity, receivedMessage.CreatedAt, receivedMessage.UpdatedAt); using (var scope = _serviceScopeFactory.CreateScope()) { _productService = scope.ServiceProvider.GetService <IProductService>(); _updateProduct = scope.ServiceProvider.GetService <IUpdateProduct>(); var product = _productService.GetById(receivedMessage.ProductId); _updateProduct.UpdateItem(product, sale, receivedMessage); return(Task.CompletedTask); } }
public ProductController( IAddProduct addProduct, IGenerateInitialProducts generateInitialProducts, IGetProduct getProduct, IGetProducts getProducts, IDeleteProduct deleteProduct, IUpdateProduct updateProduct, IDeleteAllProducts deleteAllProduct, ISearchProduct searchProduct) { _addProduct = addProduct; _generateInitialProducts = generateInitialProducts; _getProduct = getProduct; _getProducts = getProducts; _deleteProduct = deleteProduct; _updateProduct = updateProduct; _deleteAllProducts = deleteAllProduct; _searchProduct = searchProduct; }
public async Task <BaseResponse> UpdateProduct(ProductContract prd, IUpdateProduct exec) { return(await exec.Execute(prd)); }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <returns></returns> public async Task <Product> Update(IUpdateProduct data) { var existCode = _context.Product.Find(f => f.CompanyId == data.CompanyId && f.IsDelete == false && f.ProductCode == data.ProductCode && data.Id != f.Id).FirstOrDefault(); if (existCode == null) { var filter = Builders <Product> .Filter.Eq("Id", data.Id); filter &= Builders <Product> .Filter.Eq("CompanyId", data.CompanyId); var update = Builders <Product> .Update .Set(s => s.UpdatedBy, data.UpdatedBy) .CurrentDate(s => s.UpdatedAt); foreach (var column in data.Columns) { switch (column) { case "ProductCode": update = update.Set(s => s.ProductCode, data.ProductCode); break; case "ProductCategoryId": update = update.Set(s => s.ProductCategoryId, data.ProductCategoryId); break; case "Name": update = update.Set(s => s.Name, data.Name); break; case "Unit": update = update.Set(s => s.Unit, data.Unit); break; case "Price": update = update.Set(s => s.Price, data.Price); break; case "Desc": update = update.Set(s => s.Desc, data.Desc); break; case "Status": update = update.Set(s => s.Status, data.Status); break; } } var options = new FindOneAndUpdateOptions <Product> { ReturnDocument = ReturnDocument.After }; var product = await _context.Product.FindOneAndUpdateAsync(filter, update, options); return(product); } return(new Product() { Id = "-1" }); }
public async Task <JsonResult> UpdateProduct(ProductModel prd, [FromServices] IUpdateProduct fsd) { return(new JsonResult(await _productCatalogueServiceFacade.UpdateProduct(_mapper.Map <ProductContract>(prd), fsd))); }