public async Task <IActionResult> TrainersAll() { var trainers = await this.usersService.GetAllTrainersAsync(); UsernamesAndTrainerNameModel model = new UsernamesAndTrainerNameModel { Trainers = trainers, TrainerName = string.Empty, }; if (trainers.Count() == 0) { this.ViewData["Errors"] = GlobalConstants.NoTrainersErrorMessage; } return(this.View(model)); }
public async Task <IActionResult> ChooseTrainer(UsernamesAndTrainerNameModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var currnetUser = await this.usersService.GetUserByUsernameAsync(this.User.Identity.Name); if (currnetUser.Weight == null || currnetUser.Height == null) { var modelForEditView = new ClientViewModel() { TrainerName = model.TrainerName }; return(this.View("EditWeightHeight", modelForEditView)); } await this.usersService.SetTrainerAsync(model.TrainerName, this.User.Identity.Name); var trainer = await this.usersService.GetUsersTrainerAsync(this.User.Identity.Name); return(this.View("MyTrainer", trainer)); }