public IActionResult AssignTractor(AssignTractorViewModel assignTractorViewModel)
        {
            if (ModelState.IsValid)
            {
                //Employee employee = new Employee()
                //{
                //    EmployeeID = assignTractorViewModel.EmployeeID,
                //    TractorID = assignTractorViewModel.TractorID
                //};


                Employee driver = empRepo.GetEmployeeWithId(assignTractorViewModel.EmployeeID);
                Tractor  truck  = truRepo.GetTractorWithId(assignTractorViewModel.TractorID);

                //this is where you need to update DriverTractorAssignmentHistory or do it in the repo.AssignTractor for abstraction purposes
                empRepo.AssignTractor(driver.EmployeeID, truck.TractorID);

                // changes the availability of tractor once assigned
                truRepo.ChangeStatusWithId(driver.TractorID.GetValueOrDefault());

                //adds it to drivertractor history
                dtRepo.AddHistory(driver, truck);

                return(Redirect("/Employee"));
            }
            ;
            return(View(assignTractorViewModel));
        }
Пример #2
0
        //gets details for individual trailer mapped by id
        public IActionResult TractorDetails(int id)
        {
            Tractor tractorinfo = repo.GetTractorWithId(id);

            return(View(tractorinfo));
        }