/// <summary>
        /// GET: Product/Details/ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>

        public ActionResult Details(int id)
        {
            DetailsProductViewModel detailsProductViewModel = new DetailsProductViewModel();

            detailsProductViewModel.Products = businessManager.GetProductById(id);
            detailsProductViewModel.Log      = businessManager.getAllLogProduit();
            return(View(detailsProductViewModel));
        }
        public ActionResult Details(int id)
        {
            var userId = User.Identity.GetUserId();
            DetailsProductViewModel vm = new DetailsProductViewModel();

            vm.Product = productService.GetById(id);
            vm.Images  = productService.ViewImages(id);
            vm.IsProductOfCurrentUser = orderManager.IsProductOfCurrentUser(userId, id);
            return(View(vm));
        }
Esempio n. 3
0
        public IActionResult Details(int id)
        {
            var result = new DetailsProductViewModel()
            {
                DetailsProductModel = this.adminServices.DetailsProduct(id)
            };

            if (result == null)
            {
                TempData["_Message"] = "Details is wrong !!!";
                return(RedirectToAction(nameof(AllProduct)));
            }
            return(View(result));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, DetailsProductViewModel detailsProductViewModel, IFormFile ImageUp)
        {
            if (id != detailsProductViewModel.ProductId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (ImageUp != null)
                    {
                        if (detailsProductViewModel.ProductImage == null)
                        {
                            detailsProductViewModel.ProductImage = Guid.NewGuid().ToString() + Path.GetExtension(ImageUp.FileName);
                        }

                        string savePath = Path.Combine(
                            Directory.GetCurrentDirectory(), "wwwroot/ProductImages", detailsProductViewModel.ProductImage
                            );

                        await using (var stream = new FileStream(savePath, FileMode.Create))//ذخیره ی عکس
                        {
                            await ImageUp.CopyToAsync(stream);
                        }
                    }
                    var productModel = _mapper.Map <Product>(detailsProductViewModel);

                    _productRepository.UpdateEntity(productModel);
                    _productRepository.Save();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(detailsProductViewModel.ProductId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductGroupId"] = new SelectList(_productGroupRepository.GetAllEntities(), "ProductGroupId", "ProductGroupTitle", detailsProductViewModel.ProductGroupId);
            return(View(detailsProductViewModel));
        }
        // GET: Product/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            DetailsProductViewModel viewModel = new DetailsProductViewModel();

            viewModel.Product = await _context.Producten
                                .Include(p => p.ProductType)
                                .FirstOrDefaultAsync(m => m.ProductID == id);

            if (viewModel.Product == null)
            {
                return(NotFound());
            }

            return(View(viewModel));
        }
Esempio n. 6
0
        public DetailsProductViewModel GetDetailsProductById(string productId)
        {
            var product = this.CheckNullExistsReturnProduct(productId);

            var model = new DetailsProductViewModel()
            {
                Id           = product.Id,
                Name         = product.Name,
                ImageUrl     = product.ImageUrl != null ? product.ImageUrl : GlobalConstants.DefaultProductImage,
                CategoryId   = product.CategoryId,
                CategoryName = product.Category.Name,
                Allergens    = product.Allergens
                               .Select(c => new DetailsAllergenViewModel()
                {
                    Id       = c.AllergenId,
                    Name     = c.Allergen.Name,
                    ImageUrl = c.Allergen.ImageUrl,
                }).ToList(),
            };

            return(model);
        }
Esempio n. 7
0
        public IActionResult Details(int id)
        {
            var product = this.productServices.GetProductById(id);

            if (product == null)
            {
                return(NotFound());
            }
            var link = "";

            if (product.YouTubeLink == "xx")
            {
                link = product.YouTubeLink;
            }
            else
            {
                link = youTubeEmbed + product.YouTubeLink;
            }


            var DetailsProductViewModel = new DetailsProductViewModel()
            {
                Id           = product.Id,
                Title        = product.Title,
                Price        = product.Price,
                Quantity     = product.Quantity,
                ProductTypes = product.ProductTypes.ToString(),
                Author       = product.Author,
                Description  = product.Description,
                ISBN         = product.ISBN,
                Picture      = product.Picture,
                Publishing   = product.Publishing,
                YouTubeLink  = link
            };

            return(View(DetailsProductViewModel));
        }