public async Task <IActionResult> DeleteProductsByIdsAsync([FromBody] List <int> idsList) { if (idsList == null) { return(Error("Invalid Payload")); } if (!idsList.Any()) { return(Error("Empty Products Ids List")); } var userId = GetUserIdFromClaim(); _logger.LogInformation($"Deleting Productss: {string.Join(",", idsList)}, Requested By:{userId}"); ProductsContract products = new ProductsContract(); products.StatementType = "Delete"; var command = new AddOrUpdateProductsCommand { Products = products, UserId = GetUserIdFromClaim() }; var result = await _messages.Dispatch(command).ConfigureAwait(false); return(Ok(result)); }
public async Task <IActionResult> UpdateProductsAsync([FromBody] ProductsContract products) { if (products == null) { return(Error("Invalid Payload")); } else if (products.Id < 1) { return(Error("Invalid products id")); } _logger.LogInformation($"Updating products: ${products.Id}"); products.StatementType = "Update"; var command = new AddOrUpdateProductsCommand { Products = products, UserId = GetUserIdFromClaim() }; var result = await _messages.Dispatch(command).ConfigureAwait(false); return(Ok(result)); }
public async Task <IActionResult> DeleteProductsAsync(int productsId) { if (productsId < 1) { return(Error("Invalid Products Id")); } var userId = GetUserIdFromClaim(); _logger.LogInformation($"Deleting Products: ${productsId}, Requested By:${userId}"); ProductsContract products = new ProductsContract(); products.StatementType = "Delete"; products.Id = productsId; var command = new AddOrUpdateProductsCommand { Products = products, UserId = GetUserIdFromClaim() }; var result = await _messages.Dispatch(command).ConfigureAwait(false); return(Ok(result)); }