コード例 #1
0
        public async Task <IActionResult> Create([Bind("ID,firstName,lastName,DoB")] Child child)
        {
            if (ModelState.IsValid)
            {
                _context.Add(child);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(child));
        }
        public async Task <IActionResult> Create([Bind("ID,firstName,lastName,email,phone")] Parent parent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(parent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(parent));
        }
        public async Task <IActionResult> Create([Bind("ID,firstName,lastName")] Instructor instructor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(instructor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(instructor));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("ID,Name")] BGCProgram bGCProgram)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bGCProgram);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bGCProgram));
        }
        public async Task <IActionResult> Create([Bind("ID,From,To,Body")] Message message)
        {
            if (ModelState.IsValid)
            {
                _context.Add(message);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(message));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,PushEndpoint,PushP256DH,PushAuth,ParentID")] Sub sub)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sub);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            PopulateSelectLists(sub);
            return(View(sub));
        }
        public async Task <IActionResult> Create([Bind("ID,Location,BGCProgramID")] Section section)
        {
            if (ModelState.IsValid)
            {
                _context.Add(section);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BGCProgramID"] = new SelectList(_context.BGCProgram, "ID", "ID", section.BGCProgramID);
            return(View(section));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,email")] Instructor instructor)
        {
            instructor.email = User.Identity.Name;
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(instructor);
                    await _context.SaveChangesAsync();

                    UpdateUserNameCookie(instructor.FullName);
                    return(RedirectToAction(nameof(Details)));
                }
            }
            catch (DbUpdateException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            return(View(instructor));
        }