コード例 #1
0
        public ActionResult Create([Bind(Include = "CompanyId,CompanyName,CompanyLocation,JobTitle")] Company company)
        {
            if (ModelState.IsValid)
            {
                db.Companies.Add(company);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(company));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "ProjectId,ProjectName,StartMonth,EndMonth,StartYear,EndYear,Current,ProjectDescription,TechnologiesUsed,Role,CompanyId")] Project project)
        {
            if (ModelState.IsValid)
            {
                db.Projects.Add(project);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CompanyId = new SelectList(db.Companies, "CompanyId", "CompanyName", project.CompanyId);
            return(View(project));
        }