예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("SavedPicID,UserID,PicID")] SavedPics savedPics)
        {
            if (id != savedPics.SavedPicID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(savedPics);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SavedPicsExists(savedPics.SavedPicID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PicID"]  = new SelectList(_context.pictures, "PicID", "StoragePath", savedPics.PicID);
            ViewData["UserID"] = new SelectList(_context.users, "UserID", "UserID", savedPics.UserID);
            return(View(savedPics));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("SavedPicID,UserID,PicID")] SavedPics savedPics)
        {
            if (ModelState.IsValid)
            {
                _context.Add(savedPics);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PicID"]  = new SelectList(_context.pictures, "PicID", "StoragePath", savedPics.PicID);
            ViewData["UserID"] = new SelectList(_context.users, "UserID", "UserID", savedPics.UserID);
            return(View(savedPics));
        }