コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ofID,ofName,ofEmail,ofPassword")] Officer officer)
        {
            if (id != officer.ofID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(officer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OfficerExists(officer.ofID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(officer));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("SchoolID,SchoolCode,SchoolName,orgID")] school school)
        {
            if (id != school.SchoolID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(school);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!schoolExists(school.SchoolID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(school));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("orgID,orgName,orgPhone,orgEmail,orgPassword")] Organizer organizer)
        {
            if (ModelState.IsValid)
            {
                if (organizer.orgID == 0)
                {
                    _context.Add(organizer);
                }

                else
                {
                    _context.Update(organizer);
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(organizer));
        }