/// <summary> /// Updates the address and about data on the mentor profile /// </summary> /// <returns></returns> public async Task <IActionResult> OnPostAsync() { //checks to see if model state is valid if (!ModelState.IsValid) { return(Page()); } //Gets the mentor profile based on the username var user = await _context.GetMentorAsync(this.Username); //checks to see if user is null if (user == null) { return(Redirect("/Error")); } var Mentor = user.Mentor; //Adds the address data entered to the mentors database Mentor.Address.City = Address.City; Mentor.Address.State = Address.State; Mentor.Address.StreetAddress = Address.StreetAddress; Mentor.Address.StreetAddress2 = Address.StreetAddress2; Mentor.Address.ZipCode = Address.ZipCode; await _context.SaveChangesAsync(); //Adds the about data to the mentor profile await _context.AddMentorAboutAsync(Mentor, About); return(RedirectToPage("./Details")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var user = await _context.GetAppUserAsync(Username); if (user == null) { return(NotFound($"Unable to load user with ID '{Username}'.")); } var mentor = user.Mentor; if (mentor == null) { return(Redirect("/Error")); } await _context.AddMentorAboutAsync(mentor, Input.About); return(Redirect("./Address")); }