private async void GetMoreInfo(object sender, EventArgs e) { Button button = (Button)sender; string product_to_search = (string)button.CommandParameter; Product button_product = Products.Find(Products => Products.Item_id == product_to_search); HttpResponseMessage response = await GetProduct.GetProductPriceHistory(button_product.Item_id); if (response.IsSuccessStatusCode) { string response_content = await response.Content.ReadAsStringAsync(); List <Price> prices = JsonConvert.DeserializeObject <List <Price> >(response_content); await Navigation.PushAsync(new ProductInfoPage(button_product, prices)); } else { if (response.StatusCode == System.Net.HttpStatusCode.BadGateway) { await DisplayAlert("Try Again!", "No connection with the server", "OK"); } if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) { List <Price> prices = new List <Price>(); await Navigation.PushAsync(new ProductInfoPage(button_product, prices)); } } }
public IActionResult Create(GetProduct getProduct) { Products products = new Products(); products.Name = getProduct.Name; products.Price = getProduct.Price; products.Amount = getProduct.Amount; products.Detail = getProduct.Detail; products.Type = getProduct.ImageFile.ContentType; using (Stream inputStream = getProduct.ImageFile.OpenReadStream()) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } products.Image = memoryStream.ToArray(); } var context = new istoreContext(); //context.Add<Products>(products); context.Products.Add(products); context.SaveChanges(); return(RedirectToAction("details", new { id = products.Id })); }
public virtual async Task Consume(ReceiveContext <OrderItemAdded> messageContext) { var message = messageContext.Message; var orderStatus = await this.GetOrderStatus(message.OrderStatus); this.uow.Update <OrderReview>() .SetReference(o => o.OrderTotal, message.OrderTotal) .SetValue(o => o.OrderStatusDescription, orderStatus.Description) .Where(o => o.Id, message.OrderId); var request = new GetProduct(message.OrderItem.ProductId); var product = await this.requestBus.Request <GetProduct, Product>(request); var item = new OrderItem( message.OrderId, message.OrderItem.LineNumber, product.Name, message.OrderItem.Quantity, message.OrderItem.Price); this.uow.Add(item); await this.uow.Save(); if (message.OrderStatus == OrderStatusEnum.OrderSuspended) { var response = new OrderStatusResponse(orderStatus.LongDescription); await messageContext.Respond(response); } }
public async Task <IActionResult> UpdateProduct( [FromForm] ProductForm form, [FromServices] GetProduct getProduct, [FromServices] UpdateProduct updateProduct, [FromServices] S3Client s3Client) { var product = getProduct.Do(form.Id); product.Description = form.Description; product.Series = form.Series; product.StockDescription = form.StockDescription; if (form.Images != null && form.Images.Any()) { product.Images = new List <Image>(); var results = await Task.WhenAll(UploadFiles(s3Client, form.Images)); product.Images.AddRange(results.Select((path, index) => new Image { Index = index, Url = path, })); } await updateProduct.Update(product); return(Ok()); }
private async void OnSearchPressed(object sender, EventArgs e) { SearchBar searchBar = (SearchBar)sender; EbaySearch search = new EbaySearch(searchBar.Text); string json = JsonConvert.SerializeObject(search); HttpResponseMessage response = await GetProduct.GetProducts(json); if (response.IsSuccessStatusCode) { string response_content = await response.Content.ReadAsStringAsync(); Products = JsonConvert.DeserializeObject <List <Product> >(response_content); MyCollectionView.ItemsSource = Products; } else { if (response.StatusCode == System.Net.HttpStatusCode.BadGateway) { await DisplayAlert("Try Again!", "No connection with the server", "OK"); } if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) { await DisplayAlert("Try Again!", "Invalid request", "OK"); } } }
private static void FullGetSeveralProductsTest(List <Product> products, GetProduct getProductByKey) { foreach (var product in products) { TestGetProductCopy(product, getProductByKey); } }
//[Authenticate] public ProductResponse Get(GetProduct request) { using (Profiler.Current.Step("Returning the Product Response")) { return(default(ProductResponse)); } }
public ProductsPro Retreive(GetProduct request) { var product = new ProductsPro(); var objDalProduct = new DalProduct(); product = objDalProduct.SelectProductDetail(request.Name.ToLower().Replace("-", " ")); return(product); }
public List <ProductsPro> ListRetreive(GetProduct request) { List <ProductsPro> lstProductsPro = new List <ProductsPro>(); DalProduct objDalProduct = new DalProduct(); lstProductsPro = objDalProduct.SelectProductList(request); return(lstProductsPro); }
public object Get(GetProduct request) { return(new ProductResponse() { Id = 1, Name = "Product" }); }
private static void FullSeveralProductsTest(List <string> names, GetProduct getProductByName, GetProduct getProductByKey, GetProductNameByKey getNameByKey) { foreach (var name in names) { FullProductTest(name, getProductByName, getProductByKey, getNameByKey); } }
public AdminProductsBlazorService(GetProducts getProducts, GetProduct getProduct, CreateProduct createProduct, DeleteProduct deleteProduct, UpdateProduct updateProduct) { _getProducts = getProducts; _getProduct = getProduct; _createProduct = createProduct; _deleteProduct = deleteProduct; _updateProduct = updateProduct; }
private static List <string> CreateProducts(int count, GetProduct addProduct) { var names = GetRandomProductsNames(count); names.ForEach(n => addProduct?.Invoke(n)); return(names); }
private static void FullProductTest(string name, GetProduct getProductByName, GetProduct getProductByKey, GetProductNameByKey getNameByKey) { var product = TestProductByName(name, getProductByName); TestProductByKey(name, product.Key, getProductByKey); TestProductNameByKey(product.Name, product.Key, getNameByKey); }
static void Main(string[] args) { using (var qsim = new QuantumSimulator()) { System.Console.WriteLine("Product of 6 and 8 is"); var result = GetProduct.Run(qsim, 6, 8).Result; System.Console.WriteLine(result); } }
private MessageBase GetProduct(GetProduct message) { if (!_products.TryGetValue(message.ProductId, out var product)) { return(new ProductNotFound(message.CorrelationId)); } return(new ProductFound(message.CorrelationId, product)); }
public async Task <IActionResult> OnGet(string name, [FromServices] GetProduct getProduct) { Product = await getProduct.ExecAsync(name.Replace("-", " ")); if (Product == null) { return(RedirectToPage("Index")); } return(Page()); }
public IActionResult OnGet(string slug, [FromServices] GetProduct getProduct) { SelectedProduct = getProduct.Do(slug); if (SelectedProduct == null) { return(RedirectToPage("/not-found")); } return(Page()); }
public ProductResponse Get(GetProduct request) { return(new ProductResponse { Id = 1, Name = "Product", Status = new Status { Id = 1, Name = "Active" } }); }
public async Task <ActionResult <ProductDto> > GetAsync([FromRoute] GetProduct query) { var product = await _dispatcher.QueryAsync(query); if (product is null) { return(NotFound()); } return(product); }
public object Get(GetProduct request) { var product = documentSession.Load <Product>(request.Id); if (product == null) { HttpError.NotFound("Product not found!"); } return(new ProductDto().PopulateWith(product)); }
/// <summary> /// todo - ???? what is this? /// </summary> public async void SendProductPDF() { var product = new GetProduct(_context, _discounts); var result = await _viewRenderService.RenderToStringAsync("/Pages/Shop/Product.cshtml", product); var file = await _pdfService.GetProductAsPdf(result); _emailSender.SendProductPDF(new EmailSender.Request { EmailAddress = "*****@*****.**" }); }
public IActionResult OnGet(string name) { Product = new GetProduct(_ctx).Do(name.Replace("-", " ")); if (Product == null) { return(RedirectToPage("Index")); } else { return(Page()); } }
//获取指定产品详情: public ProductResponse Get(GetProduct request) { ProductResponse result = ProductRepository.GetProduct(request); if (result == null) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(default(ProductResponse)); } return(result); }
public Product Get(GetProduct request) { var product = request.Id.HasValue ? products.FirstOrDefault(x => x.Id == request.Id.Value) : products.FirstOrDefault(x => x.Name == request.Name); if (product == null) { throw new HttpError(HttpStatusCode.NotFound, "Product does not exist"); } return(product); }
private static void FullRemoveProductTest(string name, string key, GetProduct getProductByName, GetProduct getProductByKey, GetProductNameByKey getNameByKey) { var product = getProductByName?.Invoke(name); Assert.Null(product); product = getProductByKey?.Invoke(key); Assert.Null(product); name = getNameByKey?.Invoke(key); Assert.Null(name); }
public async Task <IActionResult> OnGet(string name, [FromServices] GetProduct getProduct) { Product = await getProduct.DoAsync(int.Parse(name)); if (Product == null) { return(RedirectToPage("Index")); } else { return(Page()); } }
public async Task <int> GeStocks(int productId, int stockId, [FromServices] GetProduct getProduct) { var product = await getProduct.DoAsync(productId); var stock = product.Stock.FirstOrDefault(x => x.Id == stockId); if (stock == null) { return(0); } return(stock.Qty); }
//returns all the Products public ProductResponse Get(GetProduct request) { var product = ProductRepository.GetById(request.Id); if (product == null) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(default(ProductResponse)); } //transform to ProductsResponse and return. return(ProductMapper.ToProductResponse(product)); }
public async Task return_null_when_not_found_document() { //Arrange _productRepository.Setup(r => r.GetAsync(_guid)).Returns(Task.FromResult((Product)null)); var query = new GetProduct(); //Act var handler = new GetProductHandler(_productRepository.Object, _logger.Object); var result = await handler.HandleAsync(query); //Assert Assert.Null(result); }
public object Get(GetProduct request) { var product = documentSession.Load<Product>(request.Id); if (product == null) HttpError.NotFound("Product not found!"); return new ProductDto().PopulateWith(product); }