public ActionResult AddEmployee(FullEmployeeViewModel model) { var counter = employeeService.GetEmployees().Last(); var counterId = counter.EmployeeId + 1; model.EmployeeId = counterId; var deps = departmentService.GetDepartments(); var depNames = from x in deps select x.Name; var positions = positionService.GetPositions(); var posNames = from x in positions select x.Name; if (depNames.Contains(model.DepartmentName)) { if (posNames.Contains(model.Position)) { var depId = deps.Where(x => x.Name == model.DepartmentName).FirstOrDefault().DepartmentId; var posId = positions.Where(x => x.Name == model.Position).FirstOrDefault().PositionId; EmployeeDTO newEmpl = new EmployeeDTO { EmployeeId = model.EmployeeId, Name = model.Name, Surname = model.Surname, Experience = model.Experience, PaymentNum = model.PaymentNum, DepartmentId = depId, PositionId = posId }; employeeService.AddEmployee(newEmpl); } } return RedirectToAction("Index", "Home"); }
public ActionResult AddEmployee() { var employee = new FullEmployeeViewModel { EmployeeId = 0 }; return View(employee); }