Example #1
0
        public async Task <IActionResult> ProductImageUpdate(int?id)
        {
            var productImageInDb = await _productImageService.GetWithProductByIdAsync(id.Value);

            if (productImageInDb == null)
            {
                return(RedirectToAction("Index").ShowMessage(Status.Error, "Hata", "Ürün resmi bulunamadı!"));
            }

            if (!await _productService.ProductExistsAsync(productImageInDb.ProductId))
            {
                return(RedirectToAction("Index").ShowMessage(Status.Error, "Hata", "Ürün bulunamadı!"));
            }

            var productInDb = await _productService.FindByIdAsync(productImageInDb.ProductId);

            productInDb.ShowImageUrl = productImageInDb.ImageUrl;
            await _productService.UpdateAsync(productInDb);

            return(RedirectToAction("Index").ShowMessage(Status.Ok, "Başarılı", "Ürün ana resmi başarıyla değiştirildi."));
        }