public IActionResult AddUser(UserModel newUser)
 {
     // if model created from form passes validation set using data annotations
     if (ModelState.IsValid)
     {
         // add the object created from form to db set
         _context.users.Add(newUser);
         // save changes to db
         _context.SaveChanges();
         // redirect to the ViewAll method in the Primary Controller
         return(RedirectToAction("ViewAll", "Primary"));
     }
     else
     // if model created from form does not pass validation set using data annotations
     {
         string displayErr = ""; // string to build
         // method to return errors from inValid model
         List <string> errors = GetErrorListFromModelState(ModelState);
         // iterate through errors from invalid model and append each to display string
         errors.ForEach(err => displayErr += $" {err} ");
         // add message to view data dictionary
         ViewData["errors"] = displayErr;
         // render UserForm view and pass invalid model
         return(View("userForm", newUser));
     }
 }
 public IActionResult CreateBand(BandModel newBand)
 {
     if (ModelState.IsValid)
     {
         _context.bands.Add(newBand);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("CreateBandForm", newBand));
     }
 }
 public IActionResult AddProfessor(ProfessorModel newProf)
 {
     // if object passed to endpoint meets model validation
     if (ModelState.IsValid)
     {
         // add to db
         _context.professors.Add(newProf);
         _context.SaveChanges();
         // redirect to Index method
         return(RedirectToAction("Index"));
     }
     else
     // if object does not meet model validation
     {
         // display form again with invalid info
         return(View("CreateForm", newProf));
     }
 }