/// <summary> /// Converts a <see cref="BusinessEntities.Student"/> class to a <see cref="Model.Student"/> /// class. The BusinessEntities.Student class is referenced by this Business Logic Layer /// while the Model.Student class is referenced by the Data Access Layer. /// </summary> /// <param name="businessStudent">The instance of the BusinessEntities.Student class.</param> /// <returns>A corresponding instance of the Model.Student class.</returns> public Model.Student ToModel(BusinessEntities.Student businessStudent) { Model.Student modelStudent = new Model.Student(); modelStudent.Id = businessStudent.Id; modelStudent.Firstname = businessStudent.Firstname; modelStudent.Surname = businessStudent.Surname; modelStudent.DOB = DateTime.Parse(businessStudent.DOB); modelStudent.Course = businessStudent.Course; modelStudent.YearOfStudy = (Model.YearOfStudyEnum)businessStudent.YearOfStudy; modelStudent.Address = new Model.Address(); modelStudent.Address.Address1 = businessStudent.Address.Address1; modelStudent.Address.Town = businessStudent.Address.Town; modelStudent.Address.County = businessStudent.Address.County; modelStudent.Address.PostCode = businessStudent.Address.PostCode; modelStudent.Contact = new Model.ContactDetail(); modelStudent.Contact.HomePhone = businessStudent.Contact.HomePhone; modelStudent.Contact.MobilePhone = businessStudent.Contact.MobilePhone; modelStudent.Contact.HomeEmail = businessStudent.Contact.HomeEmail; modelStudent.Contact.StudentEmail = businessStudent.Contact.StudentEmail; return(modelStudent); }
/// <summary> /// Converts a <see cref="Model.Student"/> class to <see cref="BusinessEntities.Student"/> /// class. The Model.Student class is referenced by the Data Access Layer, while the /// BusinessEntities.Student is referenced by this Business Logic Layer. /// </summary> /// <param name="modelStudent">The instance of the Model.Student class</param> /// <returns>An instance of the BusinessEntities.Student class</returns> public BusinessEntities.Student ToBusinessEntity(Model.Student modelStudent) { BusinessEntities.Student businessStudent = new BusinessEntities.Student(); businessStudent.Id = modelStudent.Id; businessStudent.Firstname = modelStudent.Firstname; businessStudent.Surname = modelStudent.Surname; businessStudent.DOB = modelStudent.DOB.ToString(); businessStudent.Course = modelStudent.Course; businessStudent.YearOfStudy = (BusinessEntities.YearOfStudyEnum)modelStudent.YearOfStudy; businessStudent.Address = new BusinessEntities.Address(); businessStudent.Address.Address1 = modelStudent.Address.Address1; businessStudent.Address.Town = modelStudent.Address.Town; businessStudent.Address.County = modelStudent.Address.County; businessStudent.Address.PostCode = modelStudent.Address.PostCode; businessStudent.Contact = new BusinessEntities.ContactDetail(); businessStudent.Contact.HomePhone = modelStudent.Contact.HomePhone; businessStudent.Contact.MobilePhone = modelStudent.Contact.MobilePhone; businessStudent.Contact.HomeEmail = modelStudent.Contact.HomeEmail; businessStudent.Contact.StudentEmail = modelStudent.Contact.StudentEmail; return businessStudent; }
/// <summary> /// Converts a <see cref="Model.Student"/> class to <see cref="BusinessEntities.Student"/> /// class. The Model.Student class is referenced by the Data Access Layer, while the /// BusinessEntities.Student is referenced by this Business Logic Layer. /// </summary> /// <param name="modelStudent">The instance of the Model.Student class</param> /// <returns>An instance of the BusinessEntities.Student class</returns> public BusinessEntities.Student ToBusinessEntity(Model.Student modelStudent) { BusinessEntities.Student businessStudent = new BusinessEntities.Student(); businessStudent.Id = modelStudent.Id; businessStudent.Firstname = modelStudent.Firstname; businessStudent.Surname = modelStudent.Surname; businessStudent.DOB = modelStudent.DOB.ToString(); businessStudent.Course = modelStudent.Course; businessStudent.YearOfStudy = (BusinessEntities.YearOfStudyEnum)modelStudent.YearOfStudy; businessStudent.Address = new BusinessEntities.Address(); businessStudent.Address.Address1 = modelStudent.Address.Address1; businessStudent.Address.Town = modelStudent.Address.Town; businessStudent.Address.County = modelStudent.Address.County; businessStudent.Address.PostCode = modelStudent.Address.PostCode; businessStudent.Contact = new BusinessEntities.ContactDetail(); businessStudent.Contact.HomePhone = modelStudent.Contact.HomePhone; businessStudent.Contact.MobilePhone = modelStudent.Contact.MobilePhone; businessStudent.Contact.HomeEmail = modelStudent.Contact.HomeEmail; businessStudent.Contact.StudentEmail = modelStudent.Contact.StudentEmail; return(businessStudent); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); // Instantiate the business layer and inject the repository. BusinessLayer.IStudentBLL BLL = new BusinessLayer.StudentBLL((App.Current as App).GetRepository()); // Get the student Id passed as the parameter. long parameterId = 0; if (e.Parameter != null && e.Parameter != string.Empty) { parameterId = (long)e.Parameter; // Get the student record student = BLL.GetStudentById(parameterId); } else { student = new BusinessEntities.Student(); } if (student != null) { // Set the form values to display the student record. SetFormValues(); // Set the button descriptions to Save and Cancel, make the Cancel button visible. this.RegisterStudent.Content = "Save"; } }
/// <summary> /// Initialises the Register Student form. /// </summary> /// <remarks> /// Move this to a helper class so that the code is separate. /// Referencing the items on the form is not obvious to me /// at the moment, MUST investigate this further. /// </remarks> private void ResetForm() { student = new Student(); this.StudentEntry.DataContext = student; //this.txtFirstNameInput.Text = string.Empty; //this.txtSurnameInput.Text = string.Empty; //this.txtDoBInput.Text = string.Empty; //this.txtCourseTitleInput.Text = string.Empty; //this.txtAddressInput.Text = string.Empty; //this.txtTownInput.Text = string.Empty; //this.txtCountyInput.Text = string.Empty; //this.txtPostCodeInput.Text = string.Empty; //this.cbYearOfStudyInput.SelectedIndex = 0; //this.txtPhoneHomeInput.Text = string.Empty; //this.txtPhoneMobileInput.Text = string.Empty; //this.txtEmailHomeInput.Text = string.Empty; //this.txtEmailStudentInput.Text = string.Empty; this.currentStudentId = 0; }
private void GetFormValues() { // create a new instance of a Student record if it's not already loaded // ie. we're in Add new student mode and not edit student mode. if (currentStudentId == 0) student = new Student(); // load Student record from onscreen values student.Firstname = this.txtFirstNameInput.Text; student.Surname = this.txtSurnameInput.Text; student.DOB = this.txtDoBInput.Text; student.Course = this.txtCourseTitleInput.Text; if (cbYearOfStudyInput.SelectedValue == null) { student.YearOfStudy = BusinessEntities.YearOfStudyEnum.First; } else { student.YearOfStudy = (BusinessEntities.YearOfStudyEnum)this.cbYearOfStudyInput.SelectedValue; } student.Address = new BusinessEntities.Address(); student.Address.Address1 = this.txtAddressInput.Text; student.Address.Town = this.txtTownInput.Text; student.Address.County = this.txtCountyInput.Text; student.Address.PostCode = this.txtPostCodeInput.Text; student.Contact = new BusinessEntities.ContactDetail(); student.Contact.HomePhone = this.txtPhoneHomeInput.Text; student.Contact.MobilePhone = this.txtPhoneMobileInput.Text; student.Contact.HomeEmail = this.txtEmailHomeInput.Text; student.Contact.StudentEmail = this.txtEmailStudentInput.Text; }
public void DeleteStudent(BusinessEntities.Student student) { Helpers helper = new Helpers(); _repository.DeleteStudent(helper.ToModel(student)); }