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")); }
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); }