public IActionResult Add(AbsenceViewModel model)
        {
            if (ModelState.IsValid)
            {
                //Check to make sure Need Coverage and Periods input match.
                List <SelectablePeriodViewModel> checkedPeriods = model.SelectablePeriods.Where(p => p.Checked == true).ToList();

                if (model.NeedCoverageInput == "true" && checkedPeriods.Count == 0)
                {
                    ModelState.AddModelError("", "If coverage is needed, please check the periods that you will need coverage for.");
                }
                else if (model.NeedCoverageInput == "false" && checkedPeriods.Count != 0)
                {
                    ModelState.AddModelError("", "If no coverage is needed, checked periods are not allowed.");
                }
                else
                {
                    //Initialize the bool value for Need Coverage in Absence Request.
                    model.AbsenceRequest.NeedCoverage = model.NeedCoverageInput == "true" ? true : false;

                    //Add the records to the joint entity AbsenceRequestPeriod (Many-to-Many), by using the method in Unit of Work.
                    data.AddNewAbsenceRequestPeriods(model.AbsenceRequest, model.SelectablePeriods);

                    //Inser the new record.
                    data.AbsenceRequests.Insert(model.AbsenceRequest);

                    //Save the changes to the database.
                    data.Save();

                    TempData["SucessMessage"] = "The Absence Request with ID# " + model.AbsenceRequest.AbsenceRequestId + ", was created successfully.";

                    return(RedirectToAction("List"));
                }
            }
            model.AbsenceTypes  = data.AbsenceTypes.List();
            model.DurationTypes = data.DurationTypes.List();
            return(View("Absence", model));
        }