[Route("BusinessUnit/{businessUnitCode}")]                                                    //route of the URL to get a specific BU - BusinessUnit/AnSrBu for instance.
        public IEnumerable <Models.StaffAttributeDTO> GetstaffByBu(string businessUnitCode)
        {                                                                                             //gets the correct DB from the Database which is the same as the URL entered.
            CFEDModel.BusinessUnit BUnit = allBusinessUnitdb.BusinessUnits.First(b => b.businessUnitCode.Equals(businessUnitCode, StringComparison.CurrentCultureIgnoreCase));
            var StaffBu     = allStaffdb.Staffs.Where(s => s.businessUnitId == BUnit.businessUnitId); //getting all staff from a specified DB.
            var staffDetail = StaffBu.Select(staff => new StaffAttributeDTO                           //creating variable to get relevant information from StaffAttributsDTO class.
            {
                staffCode = staff.staffCode,
                firstName = staff.firstName,
                lastName  = staff.lastName
            }).AsEnumerable();

            return(staffDetail); // return variable StaffDetail.
        }
        /// <summary>
        /// 'Get'ting all information from BUDto
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Models.BUDto Get(int id)
        {
            var businessUnits = db.BusinessUnits; //variable businessUnits is db.BU

            CFEDModel.BusinessUnit bUnits = businessUnits.SingleOrDefault(b => b.businessUnitId == id);

            var buDetails = new BUDto                       // created variable budetails to get relevant information from BUDTO class.
            {
                businessUnitCode = bUnits.businessUnitCode, //Specify relevant BUCode.
                title            = bUnits.title             //Specify relevant BU title.
            };

            return(buDetails); //return variable buDetails.
        }
        //Edit Existing BusinessUnit - complete all data to include ["BusinessUnitId(PK),etc etc etc etc etc ect etc etc etc"]
        public ActionResult Edit(CFEDModel.BusinessUnit businessUnit)
        {
            if (ModelState.IsValid)                                  // tells me if any errors have been added to ModelState
            {
                businessUnit.Active = true;                          //setting this to true so when the BU has been edited they the active flag stays true

                db.Entry(businessUnit).State = EntityState.Modified; // becuase model state was valid its allowing the changes to be made to businessunit

                db.SaveChanges();                                    // save changes when complete

                return(RedirectToAction("Index"));                   //returns to main page / Index where changes can be seen
            }


            return(View(businessUnit)); //otherwise return back to the view.
        }