public ActionResult Create([Bind(Include = "UserID,Username,LastLoggedIn")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
        public ActionResult Create([Bind(Include = "CategoryId,CtegoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "ToDoItemId,Item,DateDue,Done,UserId,CategoryId")] ToDoItem toDoItem)
        {
            if (ModelState.IsValid)
            {
                db.ToDoItems.Add(toDoItem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CtegoryName", toDoItem.CategoryId);
            ViewBag.UserId     = new SelectList(db.Users, "UserId", "UserName", toDoItem.UserId);
            return(View(toDoItem));
        }