コード例 #1
0
        public async Task <IActionResult> Create([Bind("UserID,Username")] Users users)
        {
            if (ModelState.IsValid)
            {
                _context.Add(users);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("BabyID,BabyName,BabyGender,BirthDate,UserID")] BabyInfo babyInfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(babyInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserID"] = new SelectList(_context.Users, "UserID", "UserID", babyInfo.UserID);
            return(View(babyInfo));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("NumberofDiaperChanges,BabyID")] DiaperChange diaperChange)
        {
            if (ModelState.IsValid)
            {
                _context.Add(diaperChange);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BabyID"] = new SelectList(_context.BabyInfo, "BabyID", "BabyID", diaperChange.BabyID);
            return(View(diaperChange));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("FeedingID,NumberOfFeedings,FeedingTime,BabyID")] Feeding feeding)
        {
            if (ModelState.IsValid)
            {
                _context.Add(feeding);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BabyID"] = new SelectList(_context.BabyInfo, "BabyID", "BabyID", feeding.BabyID);
            return(View(feeding));
        }