private VolunteerInfo GenerateOrganizerVolunteerInfo(int codeCampId) { var registration = RegistrationDataAccess.GetItemByUserId(UserInfo.UserID, codeCampId); if (registration == null) { RegistrationDataAccess.CreateItem(new RegistrationInfo() { CodeCampId = codeCampId, IsRegistered = true, Notes = "Registered automatically by Volunteer view.", RegistrationDate = DateTime.Now, ShirtSize = "XL", UserId = UserInfo.UserID }); registration = RegistrationDataAccess.GetItemByUserId(UserInfo.UserID, codeCampId); } VolunteerDataAccess.CreateItem(new VolunteerInfo() { CodeCampId = codeCampId, Notes = "Automatically generated by the Volunteer view.", RegistrationId = registration.RegistrationId }); return(VolunteerDataAccess.GetItemByRegistrationId(registration.RegistrationId, codeCampId)); }
public HttpResponseMessage GetRegistrationByUserId(int userId, int codeCampId) { try { var response = new ServiceResponse <RegistrationInfo>(); RegistrationInfo registration = null; if (userId > 0) { registration = RegistrationDataAccess.GetItemByUserId(userId, codeCampId); response.Content = registration; } if (registration == null) { ServiceResponseHelper <RegistrationInfo> .AddNoneFoundError("registration", ref response); } return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public bool Register(TestSprocGenerator.Business.SingleTable.Bo.Account accountInfo, TestSprocGenerator.Business.SingleTable.Bo.Person personInfo, TestSprocGenerator.Business.SingleTable.Bo.Address addressInfo, TestSprocGenerator.Business.SingleTable.Bo.PhoneNumber phoneNumberInfo, TestSprocGenerator.Business.SingleTable.Bo.EmailAddress emailAddressInfo, TestSprocGenerator.Business.SingleTable.Bo.ProfileType profileType) { RegistrationDataAccess registrationDataAccess = new RegistrationDataAccess(); AccountBusinessLayer.AccountManager accountManager = new AccountBusinessLayer.AccountManager(); bool exists = accountManager.DoesUserNameExist(accountInfo.AccountUsername); if (exists) { throw new ArgumentException("AccountUsername is in Use, Please pick another username"); } return(registrationDataAccess.Register((TestSprocGenerator.Data.SingleTable.Dto.Account)accountInfo, (TestSprocGenerator.Data.SingleTable.Dto.Person)personInfo, (TestSprocGenerator.Data.SingleTable.Dto.Address)addressInfo, (TestSprocGenerator.Data.SingleTable.Dto.PhoneNumber)phoneNumberInfo, (TestSprocGenerator.Data.SingleTable.Dto.EmailAddress)emailAddressInfo, (TestSprocGenerator.Data.SingleTable.Dto.ProfileType)profileType)); }
public bool IsParentProfile(TestSprocGenerator.Business.SingleTable.Bo.Account account, out TestSprocGenerator.Data.SingleTable.Dto.Profile profile) { RegistrationDataAccess registrationDataAccess = new RegistrationDataAccess(); TestSprocGenerator.Data.SingleTable.Dto.Profile_Account profile_account = null; profile = registrationDataAccess.GetProfile(account.AccountID, out profile_account); TestSprocGenerator.Business.SingleTable.Bo.ProfileType profileTypeCriteria = new TestSprocGenerator.Business.SingleTable.Bo.ProfileType() { ProfileTypeID = profile.ProfileTypeID }; TestSprocGenerator.Business.SingleTable.Bo.List.ProfileType search = new TestSprocGenerator.Business.SingleTable.Bo.List.ProfileType(_smoSettings[CONNECTION_STRING_NAME]); search.FillByCriteriaExact(profileTypeCriteria); if (search != null && search.Count > 0) { if (search[0].ProfileName.Contains("Parent")) { return(true); } } return(false); }
protected void btnAddCourseOffering_Click1(object sender, EventArgs e) { string studentNumber = txtStudentName.Text; string studentName = txtStudentName.Text; List <CourseOffering> coursesOffered = CourseOfferingsDataAccess.retreiveAllCourses(); int j = ddlCourseOffering.SelectedIndex; string test = rblStudentStatus.SelectedValue; if (rblStudentStatus.SelectedValue == "Full-Time") { Student ourStudents = new FullTimeStudent(studentNumber, studentName); StudentDataAccess.AddStudent(ourStudents); int selectedIndex = ddlCourseOffering.SelectedIndex; coursesOffered[selectedIndex].AddStudent(ourStudents); RegistrationDataAccess.addRegistration(ourStudents, coursesOffered[selectedIndex]); txtStudentName.Text = ""; txtStudentNumber.Text = ""; } else if (rblStudentStatus.SelectedValue == "Part-Time") { Student ourStudents = new PartTimeStudent(studentNumber, studentName); StudentDataAccess.AddStudent(ourStudents); int selectedIndex = ddlCourseOffering.SelectedIndex; coursesOffered[selectedIndex].AddStudent(ourStudents); RegistrationDataAccess.addRegistration(ourStudents, coursesOffered[selectedIndex]); txtStudentName.Text = ""; txtStudentNumber.Text = ""; } else if (rblStudentStatus.SelectedValue == "Co-op") { Student ourStudents = new CoopStudent(studentNumber, studentName); StudentDataAccess.AddStudent(ourStudents); int selectedIndex = ddlCourseOffering.SelectedIndex; coursesOffered[selectedIndex].AddStudent(ourStudents); RegistrationDataAccess.addRegistration(ourStudents, coursesOffered[selectedIndex]); txtStudentName.Text = ""; txtStudentNumber.Text = ""; } }
public bool DoesEmailExist(string email) { bool exists = false; RegistrationDataAccess registrationDataAccess = new RegistrationDataAccess(); TestSprocGenerator.Data.SingleTable.Dto.EmailAddress emailAssociatedWithAnAccount = registrationDataAccess.GetEmailIfAssociatedWithAValidAccount(email); if (emailAssociatedWithAnAccount != null) { exists = true; } return(exists); }
public HttpResponseMessage GetRegistration(int itemId, int codeCampId) { try { var registration = RegistrationDataAccess.GetItem(itemId, codeCampId); var response = new ServiceResponse <RegistrationInfo> { Content = registration }; return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
protected void btnAddToCourseOffering_Click(object sender, EventArgs e) { Student astudent = null; List <CourseOffering> coursesOffering = CourseOfferingDataAccess.RetrieveAllCoursesOffering(); int indx = 1; try { switch (rdbStudentType.SelectedItem.Value) { case "FullTime": astudent = new FullTimeStudent(txtStudentNumber.Text, txtStudentName.Text); break; case "PartTime": astudent = new PartTimeStudent(txtStudentNumber.Text, txtStudentName.Text); break; case "Coop": astudent = new CoopStudent(txtStudentNumber.Text, txtStudentName.Text); break; } StudentDataAccess.AddNewStudent(astudent); if (drpRegisterStudentsList.SelectedIndex != 0) { foreach (CourseOffering courseO in coursesOffering) { if (indx == drpRegisterStudentsList.SelectedIndex) { RegistrationDataAccess.AddNewRegistration(courseO, astudent); } indx++; } indx = 1; } } catch (Exception) { } populateTable(); }
public bool DeleteRegistration(string username, out bool didItExist) { bool successful = false; RegistrationDataAccess registrationDataAccess = new RegistrationDataAccess(); AccountBusinessLayer.AccountManager accountManager = new AccountBusinessLayer.AccountManager(); TestSprocGenerator.Business.SingleTable.Bo.Account account = null; didItExist = accountManager.DoesUserNameExist(username, out account); if (didItExist) { TestSprocGenerator.Data.SingleTable.Dto.Profile profile = null; bool isParentProfile = IsParentProfile(account, out profile); return(registrationDataAccess.DeleteRegistration(account, profile, isParentProfile, CommonLibrary.Base.Database.BaseDatabase.TransactionBehavior.Begin)); } else { return(successful); } }
public HttpResponseMessage UpdateRegistration(RegistrationInfo registration) { try { var originalRegistration = RegistrationDataAccess.GetItemByUserId(registration.UserId, registration.CodeCampId); var updatesToProcess = false; // only update the fields that would be udpdated from the UI to keep the DB clean if (originalRegistration.TwitterHandle != registration.TwitterHandle) { originalRegistration.TwitterHandle = registration.TwitterHandle; updatesToProcess = true; } if (originalRegistration.ShirtSize != registration.ShirtSize) { originalRegistration.ShirtSize = registration.ShirtSize; updatesToProcess = true; } if (originalRegistration.HasDietaryRequirements != registration.HasDietaryRequirements) { originalRegistration.HasDietaryRequirements = registration.HasDietaryRequirements; updatesToProcess = true; } if (originalRegistration.Notes != registration.Notes) { originalRegistration.Notes = registration.Notes; updatesToProcess = true; } if (originalRegistration.CustomProperties != null) { // parse custom properties for updates foreach (var property in originalRegistration.CustomPropertiesObj) { if (registration.CustomPropertiesObj.Any(p => p.Name == property.Name)) { // see if the existing property needs to be updated var prop = registration.CustomPropertiesObj.FirstOrDefault(p => p.Name == property.Name); if (!string.Equals(prop.Value, property.Value)) { property.Value = prop.Value; updatesToProcess = true; } } else { // delete the property originalRegistration.CustomPropertiesObj.Remove(property); updatesToProcess = true; } } } if (registration.CustomPropertiesObj != null) { // add any new properties if (originalRegistration.CustomProperties == null) { foreach (var property in registration.CustomPropertiesObj) { originalRegistration.CustomPropertiesObj.Add(property); updatesToProcess = true; } } else { foreach (var property in registration.CustomPropertiesObj.Where(property => !originalRegistration.CustomPropertiesObj.Contains(property))) { originalRegistration.CustomPropertiesObj.Add(property); updatesToProcess = true; } } } if (updatesToProcess) { RegistrationDataAccess.UpdateItem(originalRegistration); } var response = new ServiceResponse <string> { Content = SUCCESS_MESSAGE }; return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public HttpResponseMessage CreateRegistration(RegistrationInfo registration) { try { var response = new ServiceResponse <RegistrationInfo>(); if (registration.UserId <= 0) { // user isn't logged in and therefore doesn't likely have a user account on the site // we need to register them into DNN for them var firstName = registration.CustomPropertiesObj.FirstOrDefault(p => p.Name == "FirstName").Value; var lastName = registration.CustomPropertiesObj.FirstOrDefault(p => p.Name == "LastName").Value; var email = registration.CustomPropertiesObj.FirstOrDefault(p => p.Name == "Email").Value; var portalId = int.Parse(registration.CustomPropertiesObj.FirstOrDefault(p => p.Name == "PortalId").Value); var ctlUser = new DnnUserController(); var status = ctlUser.CreateNewUser(firstName, lastName, email, portalId); switch (status) { case UserCreateStatus.DuplicateEmail: ServiceResponseHelper <RegistrationInfo> .AddUserCreateError("DuplicateEmail", ref response); break; case UserCreateStatus.DuplicateUserName: ServiceResponseHelper <RegistrationInfo> .AddUserCreateError("DuplicateUserName", ref response); break; case UserCreateStatus.Success: var user = UserController.GetUserByName(email); registration.UserId = user.UserID; UserController.UserLogin(portalId, user, PortalSettings.PortalName, string.Empty, false); break; case UserCreateStatus.UnexpectedError: ServiceResponseHelper <RegistrationInfo> .AddUserCreateError("UnexpectedError", ref response); break; case UserCreateStatus.UsernameAlreadyExists: ServiceResponseHelper <RegistrationInfo> .AddUserCreateError("UsernameAlreadyExists", ref response); break; case UserCreateStatus.UserAlreadyRegistered: ServiceResponseHelper <RegistrationInfo> .AddUserCreateError("UserAlreadyRegistered", ref response); break; default: ServiceResponseHelper <RegistrationInfo> .AddUnknownError(ref response); break; } } if (response.Errors.Count == 0) { registration.RegistrationDate = DateTime.Now; RegistrationDataAccess.CreateItem(registration); var registrations = RegistrationDataAccess.GetItems(registration.CodeCampId).OrderByDescending(r => r.RegistrationId); var savedRegistration = registrations.FirstOrDefault(r => r.UserId == registration.UserId); response.Content = savedRegistration; if (savedRegistration == null) { ServiceResponseHelper <RegistrationInfo> .AddNoneFoundError("registration", ref response); } } return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
protected void btnAddCourse_Click(object sender, EventArgs e) { string studentNumber = txtStudentNumber.Text; string studentName = txtStudentName.Text; List <CourseOffering> coursesOffered = CourseOfferingsDataAccess.retreiveAllCourses(); int j = coursesOffered.Count - 1; if (rblSortOptions.SelectedValue == "fullTime") { Student ourStudents = new FullTimeStudent(studentNumber, studentName); StudentDataAccess.AddStudent(ourStudents); List <Course> userCourse = CourseDataAccess.retreiveAllCourses(); int i = userCourse.Count() - 1; CourseOffering courseOfferedCourses = new CourseOffering(userCourse[i], coursesOffered[j].Year, coursesOffered[j].Semester); courseOfferedCourses.AddStudent(ourStudents); courseOfferedCourses.GetStudents().Sort(sortBy); RegistrationDataAccess.addRegistration(ourStudents, courseOfferedCourses); txtStudentName.Text = ""; txtStudentNumber.Text = ""; Response.Redirect(Request.RawUrl); } else if (rblSortOptions.SelectedValue == "partTime") { Student ourStudents = new PartTimeStudent(studentNumber, studentName); StudentDataAccess.AddStudent(ourStudents); List <Course> userCourse = CourseDataAccess.retreiveAllCourses(); int i = userCourse.Count() - 1; CourseOffering courseOfferedCourses = new CourseOffering(userCourse[i], coursesOffered[j].Year, coursesOffered[j].Semester); courseOfferedCourses.AddStudent(ourStudents); courseOfferedCourses.GetStudents().Sort(sortBy); txtStudentName.Text = ""; txtStudentNumber.Text = ""; Response.Redirect(Request.RawUrl); } else if (rblSortOptions.SelectedValue == "coop") { Student ourStudents = new CoopStudent(studentNumber, studentName); StudentDataAccess.AddStudent(ourStudents); List <Course> userCourse = CourseDataAccess.retreiveAllCourses(); int i = userCourse.Count() - 1; CourseOffering courseOfferedCourses = new CourseOffering(userCourse[i], coursesOffered[j].Year, coursesOffered[j].Semester); courseOfferedCourses.AddStudent(ourStudents); courseOfferedCourses.GetStudents().Sort(sortBy); txtStudentName.Text = ""; txtStudentNumber.Text = ""; Response.Redirect(Request.RawUrl); } }
protected void Page_PreRender(object sender, EventArgs e) { if (!IsPostBack) { List <CourseOffering> ourCourses = CourseOfferingsDataAccess.retreiveAllCourses(); ourCourses.Sort(sortOffering); foreach (CourseOffering course in ourCourses) { ListItem item = new ListItem(course.ToString(), course.CourseOffered.CourseNumber); ddlCourseOffering.Items.Add(item); } } if (IsPostBack) { List <CourseOffering> coursesOffered = CourseOfferingsDataAccess.retreiveAllCourses(); int selectedIndex = ddlCourseOffering.SelectedIndex; List <Student> studentsInOfferingList = RegistrationDataAccess.getStudentsFromOffering(coursesOffered[selectedIndex]); studentsInOfferingList.Sort(sortBy); if (studentsInOfferingList.Count == 0) { TableRow lastRow = new TableRow(); TableCell lastRowCell = new TableCell(); lastRowCell.Text = "There are currently no students enlisted"; lastRowCell.ForeColor = System.Drawing.Color.Red; lastRowCell.ColumnSpan = 4; lastRowCell.HorizontalAlign = HorizontalAlign.Center; lastRow.Cells.Add(lastRowCell); tblStudentRecords.Rows.Add(lastRow); } else { foreach (Student student in studentsInOfferingList) { { TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.Text = student.Number; row.Cells.Add(cell); cell = new TableCell(); cell.Text = student.Name; row.Cells.Add(cell); string studentType = student.ToString(); cell = new TableCell(); cell.Text = StudentType.getStudentType(student); row.Cells.Add(cell); tblStudentRecords.Rows.Add(row); } } } } }
protected void populateTable() { if (drpRegisterStudentsList.SelectedIndex != 0) { string courseOffer = drpRegisterStudentsList.SelectedItem.Value; List <CourseOffering> coursesOffering = CourseOfferingDataAccess.RetrieveAllCoursesOffering(); int indx = 0; foreach (CourseOffering courseO in coursesOffering) { if ((indx + 1) == drpRegisterStudentsList.SelectedIndex) { List <Student> registeredS = RegistrationDataAccess.GetRegistedStudentsByCourseOffering(courseO); if (registeredS.Count > 1) { registeredS.Sort((c1, c2) => c1.Name.CompareTo(c2.Name)); } foreach (Student student in registeredS) { TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.Text = student.Number; row.Cells.Add(cell); cell = new TableCell(); cell.Text = student.Name; row.Cells.Add(cell); cell = new TableCell(); string sType = "Not enrolled"; if (student.GetType() == typeof(FullTimeStudent)) { sType = "Full-Time"; } else if (student.GetType() == typeof(PartTimeStudent)) { sType = "Part-Time"; } else if (student.GetType() == typeof(CoopStudent)) { sType = "Co-op"; } cell.Text = sType; row.Cells.Add(cell); cell = new TableCell(); cell.Text = student.TuitionPayable().ToString(); row.Cells.Add(cell); tblCourseOfferingRegisteredStudent.Rows.Add(row); } } indx++; } lblCourseOfferingDisplay_forRegisterStudent.Text = courseOffer; } else { lblCourseOfferingDisplay_forRegisterStudent.Text = string.Empty; } }