Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,firstName,lastName,DoB")] 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)));
            }
            return(View(child));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, Byte[] RowVersion)
        {
            var instructorToUpdate = await _context.Instructor
                                     .FirstOrDefaultAsync(m => m.ID == id);

            if (await TryUpdateModelAsync <Instructor>(instructorToUpdate, "",
                                                       c => c.firstName, c => c.lastName))
            {
                try
                {
                    //Put the original RowVersion value in the OriginalValues collection for the entity
                    _context.Entry(instructorToUpdate).Property("RowVersion").OriginalValue = RowVersion;
                    _context.Update(instructorToUpdate);
                    await _context.SaveChangesAsync();

                    UpdateUserNameCookie(instructorToUpdate.FullName);
                    return(RedirectToAction(nameof(Details)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstructorExists(instructorToUpdate.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        ModelState.AddModelError("", "Unable to save changes. The record you attempted to edit "
                                                 + "was modified by another user after you received your values.  You need to go back and try your edit again.");
                    }
                }
            }
            return(View(instructorToUpdate));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Location,BGCProgramID")] Section section)
        {
            if (id != section.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(section);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SectionExists(section.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BGCProgramID"] = new SelectList(_context.BGCProgram, "ID", "ID", section.BGCProgramID);
            return(View(section));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,firstName,lastName,email,phone")] Parent parent)
        {
            if (id != parent.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(parent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ParentExists(parent.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(parent));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] BGCProgram bGCProgram)
        {
            if (id != bGCProgram.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bGCProgram);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BGCProgramExists(bGCProgram.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bGCProgram));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,From,To,Body")] Message message)
        {
            if (id != message.ID)
            {
                return(NotFound());
            }

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