Example #1
0
        public IActionResult ManageBus(BusManageViewModel viewModel)
        {
            var bus = mapper.Map <Bus>(viewModel.Bus);

            bus.BusWorker = busWorkerRepository.Get((long)bus.BusWorkerId);
            var busWithSelectedWorker = busRepository.GetBusWithWorker(viewModel.Bus.BusWorkerId);

            if (busWithSelectedWorker != null)
            {
                busWithSelectedWorker.BusWorker = null;
                busRepository.Save(busWithSelectedWorker);
            }
            busRepository.Save(bus);

            return(RedirectToAction("ManageBus", "Bus"));
        }