コード例 #1
0
 public IActionResult Create([Bind("Id,UserName,Position")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         _context.Add(employee);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(employee));
 }
コード例 #2
0
 public IActionResult Create([Bind("Id,ProjectTitle,Budget,CompletionDate")] Project project)
 {
     if (ModelState.IsValid)
     {
         _context.Add(project);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(project));
 }
コード例 #3
0
 public IActionResult Create([Bind("Id,TaskTitle,EstimatedNumberOfDays,ActualNumberOfDays,ProjectId,EmployeeId")] ProjectTask projectTask)
 {
     if (ModelState.IsValid)
     {
         _context.Add(projectTask);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["EmployeeId"] = new SelectList(_context.Employee, "Id", "Id", projectTask.EmployeeId);
     ViewData["ProjectId"]  = new SelectList(_context.Project, "Id", "Id", projectTask.ProjectId);
     return(View(projectTask));
 }