/// <summary> /// Inputs the updated address and about information to the Protege profile /// </summary> /// <returns></returns> public async Task <IActionResult> OnPostAsync() { //checks to see if model state is valid if (!ModelState.IsValid) { return(Page()); } //Gets the protege profile based on the username var user = await _context.GetProtegeAsync(this.Username); //checks to see if the user is null if (user == null) { return(Redirect("/Error")); } //Sets protege to the protege profile var Protege = user.Protege; //Adds the Inputed address data to the protege address data Protege.Address.City = Address.City; Protege.Address.State = Address.State; Protege.Address.StreetAddress = Address.StreetAddress; Protege.Address.StreetAddress2 = Address.StreetAddress2; Protege.Address.ZipCode = Address.ZipCode; await _context.SaveChangesAsync(); //Adds the About section the protege profile await _context.AddProtegeAboutAsync(Protege, About); return(RedirectToPage("./Detail")); }
/// <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()); } _context.Attach(Resource).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ResourceExists(Resource.ResourceID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
/// <summary> /// Sets the users info to what was entered in the view /// </summary> /// <returns></returns> public async Task <IActionResult> OnPostAsync() { //Checks to see if model state is valid if (!ModelState.IsValid) { return(Page()); } //Gets the client profile based on the username var user = await _context.GetClientAsync(this.Username); //Checks to see if user is null if (user == null) { return(Redirect("/Error")); } var Client = user.Client; //Sets client address fields to what was entered in the view Client.Address.City = Address.City; Client.Address.State = Address.State; Client.Address.StreetAddress = Address.StreetAddress; Client.Address.StreetAddress2 = Address.StreetAddress2; Client.Address.ZipCode = Address.ZipCode; await _context.SaveChangesAsync(); //Adds the about entered to the client await _context.AddClientAboutAsync(Client, About); return(RedirectToPage("./Detail")); }
public async Task <IActionResult> OnPostAsync() { var user = await _userManager.FindByNameAsync(User.Identity.Name); if (!ModelState.IsValid) { this.UserType = this.PopulateUserType(user); return(Page()); } var selected = this.Input.TypeId; switch (selected) { default: this.UserType = this.PopulateUserType(user); return(RedirectToPage("/")); case 0: var mentor = new Data.Mentor(); user.Mentor = mentor; await _userManager.UpdateAsync(user); await _context.SaveChangesAsync(); return(Redirect("/Mentor/ProfileBuilder/Create")); case 1: var protege = new Data.Protege(); user.Protege = protege; await _userManager.UpdateAsync(user); await _context.SaveChangesAsync(); return(Redirect("/Protege/ProfileBuilders/CreateProtege")); case 2: var Client = new Data.Client(); user.Client = Client; await _userManager.UpdateAsync(user); await _context.SaveChangesAsync(); return(Redirect("/Client/ProfileCreation/CreateClient")); } }
public async Task <IActionResult> OnPostAsync() { //Checks to see if the model state is valid if (!ModelState.IsValid) { return(Page()); } // Get the Protege var protege = await _context.GetProtegeAsync(this.Username); //Checks to see if the user is a data.protege type if not then redirects to an //error if (protege?.Protege == null) { return(Redirect("/Error")); } //gets the protege ID var protegeID = protege.Protege.ID; Input.ProtegeJoinCode = new string(Input.ProtegeJoinCode.Where(jc => !char.IsWhiteSpace(jc)).ToArray()); //Gets the Pair based off of the join code enetered var pair = _context.Pair.Where(p => p.JoinCode == Input.ProtegeJoinCode).SingleOrDefault(); //sets the pair protege ID to the users protege ID pair.ProtegeID = protegeID; //Sets the Pair protege form as the user pair.Protege = protege.Protege; await _context.SaveChangesAsync(); var protegeRole = new IdentityRole("Protege-" + pair.JoinCode); var protegeRoleSucess = await _roleManager.CreateAsync(protegeRole); if (protegeRoleSucess.Succeeded) { await _userManager.AddToRoleAsync(protege, protegeRole.Name); } else { return(RedirectToPage("/Error")); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { //Checks if the model state is valid if (!ModelState.IsValid) { return(Page()); } // Get the Client var client = await _context.GetClientAsync(this.Username); //Checks to see if the user is actually a client if (client?.Client == null) { return(Redirect("/Error")); } //gets the client ID var clientID = client.Client.ID; //Gets the Pair based off of the join code enetered Input.ClientJoinCode = new string(Input.ClientJoinCode.Where(jc => !char.IsWhiteSpace(jc)).ToArray()); var pair = _context.Pair.Where(p => p.JoinCode == Input.ClientJoinCode).SingleOrDefault(); //sets the pair protege ID to the users protege ID pair.ClientID = clientID; //Sets the Pair protege form as the user pair.Client = client.Client; await _context.SaveChangesAsync(); var clientRole = new IdentityRole("Client-" + pair.JoinCode); var clientSuccess = await _roleManager.CreateAsync(clientRole); if (clientSuccess.Succeeded) { await _userManager.AddToRoleAsync(client, clientRole.Name); } else { return(RedirectToPage("/Error")); } return(RedirectToPage("./Index")); }
/// <summary> /// Adds the Address to the user's protege profile /// </summary> public async Task <IActionResult> OnPostAsync() { //Is checking to see if the data entered does not fit what is specified in the model. If not then returns the // error page if (!ModelState.IsValid) { return(Redirect("/Error")); } //_context.Address.Add(Address); //is querying the database for the certain users address fields based off of their username and them being //a Protege var user = await _context.Users .Where(u => u.UserName == User.Identity.Name) .Include(u => u.Protege) .ThenInclude(p => p.Address) .FirstOrDefaultAsync(); var protege = user.Protege; //Checking to see if the user is null if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } //Checking to see if the user entered data into the required fields if not then it returns an error page if (AddressData == null) { return(Redirect("/Error")); } //Is setting the Protege address field to data entered by user protege.Address = AddressData; //Saving changes to the database await _context.SaveChangesAsync(); _logger.LogInformation("User with ID '{UserId}' created a Protege Profile", _userManager.GetUserId(User)); //Redirecting the page to the protege certificate page return(Redirect("./ProtegeCertificates")); }
/// <summary> /// Adds the Address to the user's client profile /// </summary> public async Task <IActionResult> OnPostAsync() { //Is checking to see if the data entered does not fit what is specified in the model. If not then returns the // redirects user to error page if (!ModelState.IsValid) { return(Redirect("/Error")); } //_context.Address.Add(Address); //is querying the database for the certain users address fields based off of their username and them being //a client var user = await _context.Users .Where(u => u.UserName == User.Identity.Name) .Include(u => u.Client) .ThenInclude(c => c.Address) .SingleOrDefaultAsync(); var client = user.Client; //Checking to see if the user is null if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } //Checking to see if the user entered data into the required fields if not then it returns an error page if (AddressClientData == null) { return(Redirect("/Error")); } //Is setting the client address field to data entered by user client.Address = AddressClientData; //Saving changes to the database await _context.SaveChangesAsync(); _logger.LogInformation("User with ID '{UserId}' created a Protege Profile", _userManager.GetUserId(User)); //Is redirecting the user to the join pairing page after they submit the form return(RedirectToPage("../Pairing/Join")); }
/// <summary> /// Deletes the specified certificate /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> OnPostAsync(int?id) { //checks to see if id passed in is null if (id == null) { return(NotFound()); } //Queries the database for the certificate based on the id passed in Certificate = await _context.Certificate.FindAsync(id); //Checks to see if certificate is not nul if not then deletes the certificate if (Certificate != null) { _context.Certificate.Remove(Certificate); await _context.SaveChangesAsync(); } return(RedirectToPage("./Detail")); }
/// <summary> /// Removes the strategic domain /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> OnPostAsync(int?id) { //checks to see if id passed is null if (id == null) { return(NotFound()); } //Gets the strategic domain based off of the id passed in StrategicDomain = await _context.StrategicDomains.FindAsync(id); //checks to see if strategic domain queried is not null and if not then remove the strategic domain if (StrategicDomain != null) { _context.StrategicDomains.Remove(StrategicDomain); await _context.SaveChangesAsync(); } return(RedirectToPage("./Details")); }
public async Task <IActionResult> OnPostAsync(int?id) { //checks to see if id is null if (id == null) { return(NotFound()); } //gets certificate based off of id Certificate = await _context.Certificate.FindAsync(id); //checks to see if certificate is not null and removes certificate if (Certificate != null) { _context.Certificate.Remove(Certificate); await _context.SaveChangesAsync(); } return(RedirectToPage("./Details")); }
/// <summary> /// Deletes the Specified areas of improvement /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> OnPostAsync(int?id) { //checks to see if id is null if (id == null) { return(NotFound()); } //Queries the database for areas of improvement based on the id passed in AreasOfImprovement = await _context.AreasOfImprovement.FindAsync(id); //checks to see if areas of improvement is not null and if not then delete areas of improvment if (AreasOfImprovement != null) { _context.AreasOfImprovement.Remove(AreasOfImprovement); await _context.SaveChangesAsync(); } return(RedirectToPage("./Detail")); }
/// <summary> /// Adds the about section to the user's protege profile /// </summary> public async Task <IActionResult> OnPostAsync() { //Is checking to see if the data entered does not fit what is specified in the model. If not then returns the // redirects user to error page if (!ModelState.IsValid) { return(Redirect("/Error")); } //is querying the database for the certain users address fields based off of their username and them being //a protege var user = await _context.Users .Where(u => u.UserName == User.Identity.Name) .Include(u => u.Protege) .FirstOrDefaultAsync(); //Checks to see if user exists if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } var protege = user.Protege; //Checks to see if user is protege if (protege == null) { return(Redirect("/Error")); } //Sets what the user entered about their company to the users profile. protege.About = Input.About; await _context.SaveChangesAsync(); _logger.LogInformation("User with ID '{UserId}' created a Protege Profile", _userManager.GetUserId(User)); return(Redirect("./ProtegeAddress")); }
/// <summary> /// Adds the certificate to the User's Protege profile /// </summary> public async Task <IActionResult> OnPostAsync() { //Is checking to see if the data entered does not fit what is specified in the model. If not then returns the // an error page if (!ModelState.IsValid) { return(Redirect("/Error")); } //is querying the database for the certain users Certificate fields based off of their username and them being //a Protege var user = await _context.Users .Where(u => u.UserName == User.Identity.Name) .Include(u => u.Protege) .ThenInclude(c => c.Certificates) .FirstOrDefaultAsync(); // Checks to see if the user is null and if the user is not a protege if (user == null && user.Protege == null) { return(Redirect("/Error")); } // Checks to see if the users certificates are null if (user.Protege.Certificates == null) { user.Protege.Certificates = new List <Certificate>(); } // Adds the inputed certificates to the users protege profile user.Protege.Certificates.Add(Certificate); _context.Certificate.Add(Certificate); await _context.SaveChangesAsync(); this.SuccessCreated = "Successfully Created a Certificate"; return(RedirectToPage()); }
/// <summary> /// Adds the users areas of improvement section to the User's Protege profile /// </summary> public async Task <IActionResult> OnPostAsync() { //Is checking to see if the data entered does not fit what is specified in the model. If not then returns the // an error page if (!ModelState.IsValid) { return(Page()); } //is querying the database for the certain users Areas of Improvement fields based off of their username and them being //a Protege var user = await _context.Users .Where(u => u.UserName == User.Identity.Name) .Include(u => u.Protege) .ThenInclude(m => m.AreasOfImprovement) .FirstOrDefaultAsync(); //Checks to see if the user is null and if the user is not a protege if (user == null || user.Protege == null) { return(Redirect("/Error")); } //Checks to see if the users Areas of Improvement are null if (user.Protege.AreasOfImprovement == null) { user.Protege.AreasOfImprovement = new List <AreasOfImprovement>(); } // Adds the inputed Areas of Improvement to the users protege profile user.Protege.AreasOfImprovement.Add(AreasOfImprovement); await _context.SaveChangesAsync(); this.SuccessfullyCreated = true; return(RedirectToPage()); }