public IActionResult EditCoachProfile(string id) { id = _userManager.GetUserId(User); var _coachProfile = _context.CoachProfiles.SingleOrDefault(m => m.UserId == id); var _user = _userManager.Users.SingleOrDefault(m => m.Id == id); if (_coachProfile == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var vmodel = new CoachProfileViewModel { UserId = id, AAUId = _coachProfile.AAUId, PersnalBio = _coachProfile.PersnalBio, YearsCoaching = _coachProfile.YearsCoaching, Wins = _coachProfile.Wins, Lossess = _coachProfile.Lossess, Achievments = _coachProfile.Achievments, Address = _coachProfile.Address, Verified = _coachProfile.Verified, StatusMessage = StatusMessage }; return(View(vmodel)); }
public IActionResult EditCoachProfile(CoachProfileViewModel vmodel, string id) { if (!ModelState.IsValid) { return(View(vmodel)); } var coachProfile = _context.CoachProfiles.SingleOrDefault(m => m.UserId == vmodel.UserId); id = coachProfile.UserId; if (coachProfile == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var AAUId = coachProfile.AAUId; var PersonalBio = coachProfile.PersnalBio; var YearsCoaching = coachProfile.YearsCoaching; var Wins = coachProfile.Wins; var Lossess = coachProfile.Lossess; var Achievements = coachProfile.Achievments; var Verified = coachProfile.Verified; if (AAUId != vmodel.AAUId) { coachProfile.AAUId = vmodel.AAUId; } if (PersonalBio != vmodel.PersnalBio) { coachProfile.PersnalBio = vmodel.PersnalBio; } if (YearsCoaching != vmodel.YearsCoaching) { coachProfile.YearsCoaching = vmodel.YearsCoaching; } if (Wins != vmodel.Wins) { coachProfile.Wins = vmodel.Wins; } if (Lossess != vmodel.Lossess) { coachProfile.Lossess = vmodel.Lossess; } if (Achievements != vmodel.Achievments) { coachProfile.Achievments = vmodel.Achievments; } if (Verified != vmodel.Verified) { coachProfile.Verified = vmodel.Verified; } _context.Update(coachProfile); _context.SaveChanges(); StatusMessage = "Your profile has been updated."; return(RedirectToAction(nameof(EditCoachProfile), "Manage", coachProfile, id)); }
public ActionResult AddAthlete(CoachProfileViewModel vm) { Athlete a = db.Athletes.FirstOrDefault(x => x.ID == vm.athItem.ID); a.TeamID = vm.teamItem.ID; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Index() { string id = User.Identity.GetUserId(); Person temp = db.Persons.FirstOrDefault(p => p.ASPNetIdentityID == id); CoachProfileViewModel coach = new CoachProfileViewModel(temp.ID); return(View("Index", coach)); }