Пример #1
0
        public ActionResult Create([Bind(Include = "CategoryId,Name,Description")] Categories categories)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(categories);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(categories));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "UserId,Name,Email,Bio")] Users users)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(users);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(users));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "PortfolioId,Title,Description,UserId,CategoryId,Image,Imagedescription,pContent")] Portfolio portfolio)
        {
            if (ModelState.IsValid)
            {
                db.Portfolio.Add(portfolio);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", portfolio.CategoryId);
            ViewBag.UserId     = new SelectList(db.Users, "UserId", "Name", portfolio.UserId);
            return(View(portfolio));
        }