protected void UpDateStudent_Click(object sender, EventArgs e) { //Validate Page Page.Validate("AdministerStudent"); if (Page.IsValid) { try { MembershipUser = (MembershipUser)Session["MembershipUser"]; UserData = (user)Session["UserData"]; //user MyUser = UserService.GetUserById(UserData.user_id); quickregistration MyReg = QuickRegService.GetObjectByUserId(UserData.user_id); if (!object.ReferenceEquals(MyReg, null)) { MyReg.admin_comments = txtAdminComments.Text; if (!object.ReferenceEquals(FirstClass.Value, "")) { MyReg.first_class = App_Code.TimeService.ConvertToUTC(Convert.ToDateTime(FirstClass.Value), UserData); } MyReg.teacher = Teacher.Text; MyReg.teacher_skypeid = TeacherSkype.Text; QuickRegService.SaveObject(MyReg); UserData.account_status = ddlStatus.SelectedItem.ToString(); UserService.SaveNewUser(UserData); App_Code.NotificationService.SendNotification("AdministerStudentSuccess", "Sucessfully Updated", "success", "4000"); } } catch (Exception ex) { App_Code.NotificationService.SendNotification("AdministerStudentError", ex.Message, "error", "4000"); } } else { App_Code.NotificationService.SendNotification("AdministerStudentValidation", "Please complete the required fields", "error", "4000"); } }
protected void Save_Click(object sender, EventArgs e) { if (UserComments.Text != "") { try { //Get the logged in User if any MembershipUser LoggedInMembershipUser; LoggedInMembershipUser = Membership.GetUser(); //Check if there is a logged in User if (LoggedInMembershipUser != null) { // ToInt32 can throw FormatException or OverflowException. int UserId = -1; //Get the RALT data from membership accountID UserId = Convert.ToInt32(LoggedInMembershipUser.ProviderUserKey.ToString()); user UserData = UserService.GetUserByMemberId(UserId); //Bind data if (!object.ReferenceEquals(UserData, null)) { quickregistration MyReg = QuickRegService.GetObjectByUserId(UserData.user_id); if (!object.ReferenceEquals(MyReg, null)) { MyReg.student_comments = UserComments.Text; QuickRegService.SaveObject(MyReg); App_Code.NotificationService.SendNotification("AdministerStudentSuccess", "Sucessfully Updated", "success", "4000"); } } } } catch (Exception ex) { App_Code.NotificationService.SendNotification("AdministerStudentError", ex.Message, "error", "4000"); } } }
protected void Register_Click(object sender, EventArgs e) { //Validate Page Page.Validate("NewAccount"); if (Page.IsValid) { //valid Page try { int MemberId = -1; //Get Loggedin User MembershipUser LoggedInMembershipUser; MembershipUser MyMemberShipUser; LoggedInMembershipUser = Membership.GetUser(); //Check if loggedin if (LoggedInMembershipUser == null) { //No loggin in User Page.Validate("NewMemberShip"); if (Page.IsValid) { string MyPassword; if (TypedPassword != "") { MyPassword = TypedPassword; } else { MyPassword = Password.Text.ToString(); } //Create User MemberId = App_Code.MemberShipService.CreateUser(UserName.Text.ToString(), MyPassword, Email.Text.ToString()); //Approve User and notify App_Code.MemberShipService.ApproveUserById(MemberId.ToString()); ////Set the HasLogInCookie //HttpCookie MyCookie = new HttpCookie("RALTHasLogin"); //MyCookie.Value = "True"; //Response.Cookies.Add(MyCookie); //Set the pageUser to the new user MyMemberShipUser = App_Code.MemberShipService.GetUserById(MemberId.ToString()); App_Code.MemberShipService.NewUserEmail(MyMemberShipUser); //App_Code.NotificationService.SendNotification("NewUserSuccess", "Your Account was created successfully, but you are not done yet. We ask that you confirm your email before we process your request. Please monitor your email for further instructions.", "success"); } else { //Invalid Page, notify User App_Code.NotificationService.SendNotification("NewAccountValidation", "Please complete the required fields", "error", "4000"); return; } } else { //UserLogged in set page user to logged in user MyMemberShipUser = LoggedInMembershipUser; //Set MemberId try { MemberId = Convert.ToInt32(MyMemberShipUser.ProviderUserKey.ToString()); } catch (Exception ex) { throw ex; } } //Check for exsisting RALTUser user RaltUser = UserService.GetUserByMemberId(MemberId); user MyUser = new user(); bool NewUser = false; //If there is an RALT USER link set UserID if (!object.ReferenceEquals(RaltUser, null)) { MyUser.user_id = RaltUser.user_id; } else { MyUser.account_status = "Request Made"; NewUser = true; } MyUser.first_name = FirstName.Text.ToString(); MyUser.member_id = MemberId; MyUser.age = Age.SelectedIndex; MyUser.email = MyMemberShipUser.Email; MyUser.last_name = LastName.Text.ToString(); MyUser.nationality = Nationality.SelectedValue; MyUser.skype_id = SkypeID.Text; //Save MyUser int MyUserId = UserService.SaveNewUser(MyUser); location RALTLocation = LocationService.GetUserById(MyUserId); location MyLocation = new location(); if (!object.ReferenceEquals(RALTLocation, null)) { MyLocation.location_id = RALTLocation.location_id; } else { RALTLocation = new location(); } //MyLocation.city = City.Text; MyLocation.country_code_iso2 = Country.SelectedValue; //MyLocation.line_1 = Address1.Text; //MyLocation.line_2 = Address2.Text; //MyLocation.postal_code = PostalCode.Text; //MyLocation.state = State.Text; MyLocation.user_id = MyUserId; int ZoneID = -1; try { ZoneID = Convert.ToInt32(TimeZone.SelectedValue); } catch (FormatException) { //Console.WriteLine("Input string is not a sequence of digits."); } catch (OverflowException) { //Console.WriteLine("The number cannot fit in an Int32."); } MyLocation.zone_id = ZoneID; LocationService.SaveObject(MyLocation); quickregistration RALTQuickReg = QuickRegService.GetObjectByUserId(MyUserId); quickregistration MyReg = new quickregistration(); if (!object.ReferenceEquals(RALTQuickReg, null)) { MyReg.quick_registration_id = RALTQuickReg.quick_registration_id; } else { RALTQuickReg = new quickregistration(); } if (!(SpanishLevel.Value == "") || !(FrequencyOfClasses.Value == "") || !(PeriodOfClasses.Value == "") || !(StartDate.Value == "")) { MyReg.languagel_evel = Convert.ToInt32(SpanishLevel.Value); MyReg.classes = Convert.ToInt32(FrequencyOfClasses.Value); MyReg.period = PeriodOfClasses.Value; // MyReg.start_date = Convert.ToDateTime(StartDate.Value); MyReg.class_duration = Convert.ToInt32(Duration.Value); DateTime LocalDate = Convert.ToDateTime(StartDate.Value); MyReg.start_date = App_Code.TimeService.ConvertToUTC(LocalDate, MyUser); } MyReg.user_id = MyUserId; MyReg.specialrequests = SpecialRequests.Text; QuickRegService.SaveObject(MyReg); if (LoggedInMembershipUser == null) { if (NewUser == true) { UserService.AccountStatusVerified(MyUserId); App_Code.EmailService.NewUserNotification(MemberId.ToString()); } //Clear Form UserName.Text = ""; Email.Text = ""; Password.Text = ""; Confirm.Text = ""; FirstName.Text = ""; LastName.Text = ""; SpecialRequests.Text = ""; Age.SelectedValue = "0"; Nationality.SelectedValue = "Default"; Country.SelectedValue = "Default"; TimeZone.SelectedValue = "0"; TimeZone.Enabled = false; Response.Redirect("/RALT/EN/Rent"); } App_Code.NotificationService.SendNotification("AccountUpdateSuccess", "Your account was updated successfully", "success", "3000"); } catch (NewUserException NUex) { App_Code.NotificationService.SendNotification("NewUserExceptionError", NUex.Message, "alert", "4000"); } catch (Exception ex) { //CreateUser Error, Notify User App_Code.NotificationService.SendNotification("NewUserError", ex.Message, "error", "4000"); } } else { //Invalid Page, notify User App_Code.NotificationService.SendNotification("NewAccountValidation", "Please complete the required fields", "error", "4000"); } }