public IActionResult ManageBusWorker(ManageBusWorkerViewModel viewModel) { var busWorker = new BusWorker(); busWorker.Certificate = certificateRepository.Get(viewModel.LicenseId); busWorker.CitizenUser = citizenUserRepository.GetUserByLogin(viewModel.CitizenLogin); busWorkerRepository.Save(busWorker); viewModel.BusWorkers = busWorkerRepository.GetAll(); return(View(viewModel)); }
private void AddBusWorkers() { var busWorkers = new List <BusWorker>() { new BusWorker { CitizenUser = citizenUserRepository.GetUserByLogin("BusWorker1"), Certificate = certificateRepository.GetByUserAndType(citizenUserRepository.GetUserByLogin("BusWorker1"), "Bus driver license") } }; foreach (var busWorker in busWorkers.Where(x => !busWorkerRepository.WorkerExists(x.CitizenUser))) { busWorkerRepository.Save(busWorker); } }