Пример #1
0
        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());
        }
Пример #2
0
        public IActionResult OnGet(string slug, [FromServices] GetProduct getProduct)
        {
            SelectedProduct = getProduct.Do(slug);

            if (SelectedProduct == null)
            {
                return(RedirectToPage("/not-found"));
            }

            return(Page());
        }
Пример #3
0
        public async Task <IActionResult> OnGet(string name, [FromServices] GetProduct getProduct)
        {
            Product = await getProduct.Do(name.Replace("-", " "));

            if (Product == null)
            {
                return(RedirectToPage("Index"));
            }
            else
            {
                return(Page());
            }
        }
 public GetProduct.Response GetProduct(int id) => _getProduct.Do(id);
Пример #5
0
 public IActionResult GetProduct([FromServices] GetProduct getProduct, int id) => Ok(getProduct.Do(id));
Пример #6
0
 public IActionResult GetProduct(
     Guid id,
     [FromServices] GetProduct getProduct) =>
 Ok(getProduct.Do(id));
Пример #7
0
 public async Task <IActionResult> GetProduct(string slug, [FromServices] GetProduct getProduct) => Ok(await getProduct.Do(slug));
 public IActionResult GetProduct(
     int id,
     [FromServices] GetProduct getProducts) =>
 Ok(getProducts.Do(id));
Пример #9
0
 public object GetProduct(int id, [FromServices] GetProduct getProduct) =>
 getProduct.Do(id);
Пример #10
0
 public async Task <IActionResult> GetProduct(int id, [FromServices] GetProduct getProduct) => Ok(await getProduct.Do(id));
 public IActionResult GetProduct([FromServices] GetProduct getProduct, int productId)
 {
     return(Json(getProduct.Do(productId)));
 }