public IActionResult EditAthleteProfile(string id) { id = _userManager.GetUserId(User); var _userProfile = _context.AthleteProfiles.SingleOrDefault(p => p.UserId == id); var user = _userManager.Users.SingleOrDefault(u => u.Id == id); if (_userProfile == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var vModel = new AthleteProfileViewModel { UserId = id, FirstName = user.FirstName, LastName = user.LastName, DateOfBirth = _userProfile.DateOfBirth, Height = _userProfile.Height, Weight = _userProfile.Weight, PersnalBio = _userProfile.PersnalBio, HighschoolName = _userProfile.HighschoolName, HighschoolCoach = _userProfile.HighschoolCoach, Position = _userProfile.Position, HSGraduationDate = _userProfile.HSGraduationDate, City = _userProfile.City, State = _userProfile.State, AAUId = _userProfile.AAUId, StatusMessage = StatusMessage }; return(View(vModel)); }
public void Convert_DateTime_FormattedString() { AthleteProfileViewModel athlete = new AthleteProfileViewModel(); var date1 = new DateTime(2008, 5, 1, 8, 30, 52); string test = athlete.ConvertToDate(date1); string expected = "05-01-2008"; Assert.That(test, Is.EqualTo(expected)); }
public ActionResult Index() { //getting id for everything string ID = User.Identity.GetUserId(); int PersonID = db.Persons.Where(r => r.ASPNetIdentityID == ID).Select(r => r.ID).First(); //logging height, weight, age, and gender of person ViewData["Height"] = db.Athletes.Where(r => r.Person.ID == PersonID).Select(r => r.Height).First(); ViewData["Weight"] = db.Athletes.Where(r => r.Person.ID == PersonID).Select(r => r.Weight).First(); ViewData["Age"] = db.Athletes.Where(r => r.Person.ID == PersonID).Select(r => r.DOB).First(); ViewData["Sex"] = db.Athletes.Where(r => r.Person.ID == PersonID).Select(r => r.Sex).First(); ViewBag.ExerciseID = new SelectList(db.Exercises, "ID", "Name"); string id = User.Identity.GetUserId(); Person temp = db.Persons.FirstOrDefault(p => p.ASPNetIdentityID == id); AthleteProfileViewModel athlete = new AthleteProfileViewModel(temp.ID); return(View("Index", athlete)); }
public ActionResult FitBit(string userID, string token) { //getting id for everything string ID = User.Identity.GetUserId(); int PersonID = db.Persons.Where(r => r.ASPNetIdentityID == ID).Select(r => r.ID).First(); //adding token and userID Person user = db.Persons.Find(PersonID); user.Athlete.FitBitUserID = userID; user.Athlete.FitBitAccessToken = token; db.SaveChanges(); ViewBag.ExerciseID = new SelectList(db.Exercises, "ID", "Name"); string id = User.Identity.GetUserId(); Person temp = db.Persons.FirstOrDefault(p => p.ASPNetIdentityID == id); AthleteProfileViewModel athlete = new AthleteProfileViewModel(temp.ID); return(View("Index", athlete)); }
public IActionResult EditAthleteProfile(AthleteProfileViewModel vmodel, string id) { if (!ModelState.IsValid) { return(View(vmodel)); } var userProfile = _context.AthleteProfiles.SingleOrDefault(u => u.UserId == vmodel.UserId); id = userProfile.UserId; if (userProfile == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var dob = userProfile.DateOfBirth; if (vmodel.DateOfBirth != dob) { userProfile.DateOfBirth = vmodel.DateOfBirth; } var height = userProfile.Height; if (vmodel.Height != height) { userProfile.Height = vmodel.Height; } var weight = userProfile.Weight; if (vmodel.Weight != weight) { userProfile.Weight = vmodel.Weight; } var personalBio = userProfile.PersnalBio; if (vmodel.PersnalBio != personalBio) { userProfile.PersnalBio = vmodel.PersnalBio; } var hsCoach = userProfile.HighschoolCoach; if (vmodel.HighschoolCoach != hsCoach) { userProfile.HighschoolCoach = vmodel.HighschoolCoach; } var hsName = userProfile.HighschoolName; if (vmodel.HighschoolName != hsName) { userProfile.HighschoolName = vmodel.HighschoolName; } var position = userProfile.Position; if (vmodel.Position != position) { userProfile.Position = vmodel.Position; } var hsGraduation = userProfile.HSGraduationDate; if (vmodel.HSGraduationDate != hsGraduation) { userProfile.HSGraduationDate = vmodel.HSGraduationDate; } var city = userProfile.City; if (vmodel.City != city) { userProfile.City = vmodel.City; } var state = userProfile.State; if (vmodel.State != state) { userProfile.State = vmodel.State; } _context.Update(userProfile); _context.SaveChanges(); StatusMessage = "Your profile has been updated."; return(RedirectToAction(nameof(EditAthleteProfile), "Manage", userProfile, id)); }