public async Task <IActionResult> Edit(int id, [Bind("ID,Title,Body,ProgramID")] 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)));
            }
            ViewData["ProgramID"] = new SelectList(_context.Programs, "ID", "ProgramDescription", announcement.ProgramID);
            return(View(announcement));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,ParentID")] Child child)
        {
            if (id != child.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(child);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ChildExists(child.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ParentID"] = new SelectList(_context.Parents, "ID", "Email", child.ParentID);
            return(View(child));
        }