public ActionResult AddCoach() { var clubs = _dbContext.Clubs.ToList(); var genders = _dbContext.Genders.ToList(); var types = _dbContext.CoachTypes.ToList(); var vm = new AddEditCoachViewModel() { Clubs = clubs, Genders = genders, Types = types }; return(View("AddEditCoach", vm)); }
public ActionResult EditCoach(int coachId) { var coach = _coachService.GetCoachById(coachId); var clubs = _dbContext.Clubs.ToList(); var genders = _dbContext.Genders.ToList(); var types = _dbContext.CoachTypes.ToList(); if (coach == null) { return(HttpNotFound()); } var vm = new AddEditCoachViewModel { Clubs = clubs, Genders = genders, Types = types }; return(View("AddEditCoach", vm)); }
public ActionResult SaveCoach(Coach coach) { if (!ModelState.IsValid) { var clubs = _dbContext.Clubs.ToList(); var genders = _dbContext.Genders.ToList(); var types = _dbContext.CoachTypes.ToList(); var vm = new AddEditCoachViewModel() { Clubs = clubs, Genders = genders, Types = types }; return(View("AddEditCoach", vm)); } _coachService.SaveCoach(coach); return(RedirectToAction("Index", "Coach")); }