protected void Button1_Click(object sender, EventArgs e) { // Create a Tutor with ROLE : TUTOR try { string username = txtUserName.Text; string password = txtPassword.Text; string cellnumber = txtCellNumber.Text; int age = Convert.ToInt32(txtAge.Text); int exp = Convert.ToInt32(txtExperience.Text); string recentdegree = txtRecentDegree.Text; string recentinstitute = txtRecentInstitute.Text; string description = txtDescription.Text; string address = txtAddress.Text; bool demo = RadioButtonList1.SelectedValue == "Yes" ? true : false; User tutor = new Models.User(); tutor.UserName = username; tutor.Password = password; tutor.CellNumber = cellnumber; tutor.Age = age; tutor.Experience = exp; tutor.RecentDegree = recentdegree; tutor.Role = "tutor"; tutor.RecentInstitute = recentinstitute; tutor.Description = description; tutor.Address = address; tutor.DemoClassCharged = Convert.ToBoolean(demo); using (TuitionContext tc = new TuitionContext()) { tc.Users.Add(tutor); tc.SaveChanges(); } //TODO: Create success page ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Added Successfully')", true); Response.Redirect("~/Login.aspx"); } catch (Exception x) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Exception. Please check!')", true); } }
private void PopulateData(string useridstr) { int userid = Convert.ToInt32(useridstr); using (TuitionContext tc = new TuitionContext()) { var temp_user = tc.Users.FirstOrDefault(x => x.UserId == userid); if (temp_user != null) { lblName.Text = temp_user.UserName; lblContacts.Text = temp_user.CellNumber + ", (" + temp_user.Address + ") "; lblAge.Text = temp_user.Age.ToString(); lbluser.Text = temp_user.Role; if (temp_user.Role.ToLower() == "tutor") { lblForExperience.Visible = true; lblExperience.Visible = true; lblExperience.Text = temp_user.Experience.ToString(); lblForRecentDegree.Text = "Recent Degree:"; lblForRecentInst.Text = "Recent Institute:"; lblForDescription.Text = "Summary:"; lblForDemo.Text = "Is Demo class charged?"; } if (temp_user.Role.ToLower() == "student") { lblForExperience.Visible = false; lblExperience.Visible = false; lblForRecentDegree.Text = "Class Studying:"; lblForRecentInst.Text = "School/College:"; lblForDescription.Text = "Requirement in words:"; lblForDemo.Text = "Is Demo class needed?"; lblForBoard.Visible = true; lblBoard.Visible = true; lblForBoard.Text = "Board of Education:"; lblBoard.Text = temp_user.BoardOfEducation; } lblRecentDegree.Text = temp_user.RecentDegree; lblRecentInst.Text = temp_user.RecentInstitute; lblDescription.Text = temp_user.Description; lblDemo.Text = temp_user.DemoClassCharged.ToString(); } } }
private void PopulateData(int userid) { using (TuitionContext tc = new TuitionContext()) { User temp_user = new User(); temp_user = tc.Users.SingleOrDefault(x => x.UserId == userid); if (temp_user != null) { lblName.Text = temp_user.UserName; lblID.Text = temp_user.UserId.ToString(); lblContacts.Text = temp_user.CellNumber + ", (" + temp_user.Address + ") "; lblAge.Text = temp_user.Age.ToString(); if (temp_user.Role.ToLower() == "tutor") { lblForExperience.Visible = true; lblExperience.Visible = true; lblExperience.Text = temp_user.Experience.ToString(); lblForRecentDegree.Text = "Recent Degree:"; lblForRecentInst.Text = "Recent Institute you have studied:"; lblForDescription.Text = "Describe Yourself:"; lblForDemo.Text = "Is Demo class charged?"; } if (temp_user.Role.ToLower() == "student") { lblForExperience.Visible = false; lblExperience.Visible = false; lblForRecentDegree.Text = "Class Studying:"; lblForRecentInst.Text = "School/College:"; lblForDescription.Text = "Requirement in words:"; lblForDemo.Text = "Is Demo class needed?"; lblForBoard.Visible = true; lblBoard.Visible = true; lblForBoard.Text = "Board of Education:"; lblBoard.Text = temp_user.BoardOfEducation; } lblRecentDegree.Text = temp_user.RecentDegree; lblRecentInst.Text = temp_user.RecentInstitute; lblDescription.Text = temp_user.Description; lblDemo.Text = temp_user.DemoClassCharged.ToString(); } } }
protected void Button1_Click(object sender, EventArgs e) { // Add the student with ROLE: Student try { string username = txtUserName.Text; string password = txtPassword.Text; string cellnumber = txtCellNumber.Text; int age = Convert.ToInt32(txtAge.Text); string classstudying = txtRecentDegree.Text; string school = txtRecentInstitute.Text; string requirement = txtDescription.Text; string address = txtAddress.Text; string board = txtBoard.Text; bool demo = RadioButtonList1.SelectedValue == "Yes" ? true : false; User student = new Models.User(); student.UserName = username; student.Password = password; student.CellNumber = cellnumber; student.Age = age; student.RecentDegree = classstudying; student.Role = "student"; student.RecentInstitute = school; student.Description = requirement; student.Address = address; student.BoardOfEducation = board; student.DemoClassCharged = Convert.ToBoolean(demo); using (TuitionContext tc = new TuitionContext()) { tc.Users.Add(student); tc.SaveChanges(); } //TODO: Create success page ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Added Successfully')", true); Response.Redirect("~/Login.aspx"); } catch (Exception x) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Exception. Please check!')", true); } }
public static string PopulateData(int userid) { //int userid = 1002; using (TuitionContext tc = new TuitionContext()) { var suggestions = tc.Users.Where(x => x.Role != (tc.Users.FirstOrDefault(y => y.UserId == userid).Role)).ToList(); string concatenated_suggestions = "<br/><br/>"; for (int i = 0; i < suggestions.Count; i++) { concatenated_suggestions = concatenated_suggestions + "<div><a href='Details.aspx?UserID=" + suggestions[i].UserId + "'>" + suggestions[i].UserId + "</a> <span> " + suggestions[i].UserName + "</span><br/><span>" + suggestions[i].Description + "</span></div><br/><hr>"; //Details.aspx } if (concatenated_suggestions != string.Empty) { return(concatenated_suggestions); } else { return("No Suggestions!"); } } }