public async Task <IActionResult> Edit(int id, [Bind("UserProductID,ImageName,Title,ProductName,Description,PriceP,Presentation")] ItemWithImage itemWithImage)
        {
            if (id != itemWithImage.UserProductID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(itemWithImage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemWithImageExists(itemWithImage.UserProductID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(itemWithImage));
        }
        public async Task <IActionResult> Create([Bind("UserProductID,ImageFile,Title,ProductName,Description,PriceP,Presentation")] ItemWithImage itemWithImage)
        {
            if (ModelState.IsValid)
            {
                // Save image to wwwroot/UserImages
                string wwwRootPath = _hostEnvironment.WebRootPath;
                string fileName    = Path.GetFileNameWithoutExtension(itemWithImage.ImageFile.FileName);
                string extension   = Path.GetExtension(itemWithImage.ImageFile.FileName);
                itemWithImage.ImageName = fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                string path = Path.Combine(wwwRootPath + "/Imagenes/", fileName);
                using (var fileStream = new FileStream(path, FileMode.Create))
                {
                    await itemWithImage.ImageFile.CopyToAsync(fileStream);
                }

                // Insert record
                _context.Add(itemWithImage);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(itemWithImage));
        }