Пример #1
0
        public async Task <IActionResult> Create([Bind("Id,LoginName,DisplayName,Password")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Title,Date,Status,Complete")] List list)
        {
            if (ModelState.IsValid)
            {
                var user = _context.Users.FirstOrDefault(u => u.LoginName == User.Identity.Name);
                list.UserId = user.Id;
                _context.Add(list);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(list));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("Description,Complete")] TodoTask todoTask)
        {
            if (ModelState.IsValid)
            {
                var user = _context.Users.FirstOrDefault(u => u.LoginName == User.Identity.Name);
                todoTask.UserId = user.Id;
                _context.Add(todoTask);
                await _context.SaveChangesAsync();

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