コード例 #1
0
ファイル: HomeController.cs プロジェクト: Husguard/DNS_Test
 public IActionResult AddEmployee(Employee adding)
 {
     _logger.LogInformation("Adding a employee: {0}, {1}, {2}, {3}", adding.Name, adding.Department.Id, adding.Post, adding.Date.ToShortDateString());
     context.AddEmployee(adding);
     _logger.LogInformation("Employee is Added. Redirect to Index");
     return(RedirectToAction("Index"));
 }
コード例 #2
0
ファイル: EmployeesContext.cs プロジェクト: Husguard/DNS_Test
        public int AddEmployee(Employee adding)
        {
            int newId = connection.AddEmployee(adding);

            adding.Id         = newId;
            adding.Department = departments.Find(x => x.Id == adding.Department.Id); // имя отдела не передаётся вместе с данными от формы
            adding.Chief      = employees.Find(x => x.Id == adding.Chief.Id);
            employees.Add(adding);
            return(newId);
        }