コード例 #1
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,OwnerId,Title,SpecialIssue,IssueNum,IssueName,Grade,Rating,Description,Own,Want")]
                                               ComicBookDetails comicBookDetails)
        {
            if (id != comicBookDetails.Id)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(comicBookDetails));
            }

            try
            {
                comicBookDetails.OwnerId = _userId;
                _context.Update(comicBookDetails);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ComicBookDetailsExists(comicBookDetails.Id))
                {
                    return(NotFound());
                }

                throw;
            }

            return(RedirectToAction(nameof(Index), new { comicBookDetails.Title.Id }));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,OwnerId,Title,SpecialIssue,IssueNum,IssueName,Grade,Rating,Description,Own,Want")]
                                                 ComicBookDetails comicBookDetails)
        {
            if (!ModelState.IsValid)
            {
                return(View(comicBookDetails));
            }
            comicBookDetails.OwnerId = _userId;
            _context.Add(comicBookDetails);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index), new { comicBookDetails.Title.Id }));
        }