コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("id,uczelnia,wydzial,autor,tytul,kategoria,opis")] Announcement announcement)
        {
            if (id != announcement.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(announcement);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnnouncementExists(announcement.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(announcement));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Body,DatePosted,Author")] Announcement announcement)
        {
            if (id != announcement.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(announcement);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnnouncementExists(announcement.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(announcement));
        }