示例#1
0
 public IActionResult AddTask(ToDoList newTask)
 {
     //assine new task userid to id,
     newTask.UserId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
     if (ModelState.IsValid)
     {
         _userdb.ToDoList.Add(newTask);
         _userdb.SaveChanges();
     }
     return(RedirectToAction("ToDoList"));
 }
示例#2
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                db.userTravel.Add(user);
                db.SaveChanges();
                ModelState.Clear();
                ViewBag.message = user.Username + "registered success";
                return(RedirectToAction("Login"));
            }

            return(View());
        }
 public ActionResult Register(UserInfo info)
 {
     if (ModelState.IsValid)
     {
         using (UserdbContext db = new UserdbContext())
         {
             db.userInfo.Add(info);
             db.SaveChanges();
         }
         ModelState.Clear();
         ViewBag.Message = info.FName + " " + info.LName + " " + "has successfully registered.";
     }
     return(View());
 }