public void DeletePerson(Person person) { using (var session = dbStore.OpenSession()) { session.Delete<Person>(person); session.SaveChanges(); } }
public void AddPerson(Person person) { using (var session = dbStore.OpenSession()) { session.Store(person); session.SaveChanges(); } }
/// <summary> /// This simulates how patient data is grabbed from the Add Patient screen /// and the patient is then persisted /// </summary> public void AddNewPatient_FullInformation() { Console.WriteLine("Testing insertion of a patient (Roberto Infante)"); //grab addresses from address section of UI //We can add one or more addresses Console.WriteLine("Grabbing Addresses"); var addresses = new List<Address> { //we grab the address type value from the SelectedValue of the AddressType dropdown //which is populated from: AddressService.GetAllAddressTypes() new Address {AddressLine1="Flat 17 - Meridian Court", AddressLine2="3, East Lane", Town="Bermondsey", StateCounty="Greater London", PostCode="SE16 4UF", Country="United Kingdom", AddressType = AddressTypeEnum.Home}, new Address {AddressLine1="Juan de Garai, 11", AddressLine2="4-D", Town="Barakaldo", StateCounty="Bizkaia", PostCode="48001", Country="Spain", AddressType= AddressTypeEnum.SecondHome} }; Console.WriteLine("Grabbing email addresses"); var emailAddresses = new List<EmailAddress> { //we grab the email address type value from the SelectedValue of the EmailType dropdown //which is populated from: AddressService.GetAllEmailAddressTypes() new EmailAddress{Address="*****@*****.**", EmailAddressType= EmailAddressTypeEnum.Private}, new EmailAddress{Address="*****@*****.**", EmailAddressType= EmailAddressTypeEnum.Work} }; Console.WriteLine("Grabbing phone numbers"); var phoneNumbers = new List<PhoneNumber> { //we grab the email address type value from the SelectedValue of the PhoneNumber dropdown //which is populated from: AddressService.GetAllPhoneNumberTypes() new PhoneNumber{Number="00447780911481", PhoneNumberType= PhoneNumberTypeEnum.PrivateMobile}, new PhoneNumber{Number="00442072316748", PhoneNumberType= PhoneNumberTypeEnum.Home} }; Console.WriteLine("Grab patient details"); var patient1 = new Person { Title = "Mr", FirstName = "Roberto", MiddleName = "Giuseppe", LastName = "Infante", Sex = "M", DateOfBirth = new DateTime(1972, 6, 1), Employer = "DevQF Limited", Qualifications = "MSc", Occupation = "IT consultant", Salutation = "Dear",//what does Salutation mean? PersonType = PersonTypeEnum.Patient,//this is hardcoded for patients//MUST make sure it is set like this Addresses = addresses, EmailAddresses = emailAddresses, PhoneNumbers = phoneNumbers }; //Persist patient Console.WriteLine("Persisting patient..."); try { peopleService.AddPerson(patient1); Console.WriteLine("Patient persisted correctly"); } catch (Exception ex) { Console.WriteLine("Failure persisting patient: {0}", ex.InnerException); } }
public void PrePopulateVariousPatients() { Person person; Console.WriteLine("Prepopulating various patients"); Console.WriteLine("Populating: Brad Pitt"); person = new Person { Title = "Mr", FirstName = "Brad", MiddleName = "", LastName = "Pitt", Sex = "M", DateOfBirth = new DateTime(1969, 4, 3), Employer = "", Qualifications = "", Occupation = "Actor", Salutation = "Dear", PersonType = PersonTypeEnum.Patient, Addresses = new List<Address>{new Address{AddressLine1="101 Long Drive",AddressLine2="Beverly Hills", Town="Los Angeles", PostCode="90001", StateCounty="California", Country="United States", AddressType=AddressTypeEnum.Home}}, EmailAddresses = new List<EmailAddress> { new EmailAddress { Address = "*****@*****.**", EmailAddressType = EmailAddressTypeEnum.Private } }, PhoneNumbers = new List<PhoneNumber> { new PhoneNumber { Number = "001 221 55589898", PhoneNumberType = PhoneNumberTypeEnum.Home } } }; Console.WriteLine("Persisting patient..."); try { peopleService.AddPerson(person); Console.WriteLine("Patient persisted correctly"); } catch (Exception ex) { Console.WriteLine("Failure persisting patient: {0}", ex.InnerException); } Console.WriteLine("Populating: Cordelia Barnes"); person = new Person { Title = "Ms", FirstName = "Cordelia", MiddleName = "", LastName = "Barnes", Sex = "F", DateOfBirth = new DateTime(1969, 4, 3), Employer = "Tesco", Qualifications = "BSc", Occupation = "Cashier", Salutation = "Dear", PersonType = PersonTypeEnum.Patient, Addresses = new List<Address>{new Address{AddressLine1="24 Bazeley Ho Library St",AddressLine2="", Town="London", PostCode="SE1 0RN", StateCounty="Greater London", Country="United Kingdom", AddressType=AddressTypeEnum.Home}}, EmailAddresses = new List<EmailAddress> { new EmailAddress { Address = "*****@*****.**", EmailAddressType = EmailAddressTypeEnum.Private } }, PhoneNumbers = new List<PhoneNumber> { new PhoneNumber { Number = "0044 207 928 0051", PhoneNumberType = PhoneNumberTypeEnum.Home }, new PhoneNumber{Number="0044 0778 0946898", PhoneNumberType= PhoneNumberTypeEnum.PrivateMobile}} }; Console.WriteLine("Persisting patient..."); try { peopleService.AddPerson(person); Console.WriteLine("Patient persisted correctly"); } catch (Exception ex) { Console.WriteLine("Failure persisting patient: {0}", ex.InnerException); } Console.WriteLine("Populating: Adam Aldridge"); person = new Person { Title = "Mr", FirstName = "Adam", MiddleName = "", LastName = "Aldridge", Sex = "M", DateOfBirth = new DateTime(1969, 4, 3), Employer = "BT", //Qualifications = "", Occupation = "telephone engineer", Salutation = "Dear", PersonType = PersonTypeEnum.Patient, Addresses = new List<Address>{new Address{AddressLine1="50 Granville Ct De Beauvoir Est",AddressLine2="", Town="London", PostCode="N1 5SP", StateCounty="Greater London", Country="United Kingdom", AddressType=AddressTypeEnum.Home}}, EmailAddresses = new List<EmailAddress> { new EmailAddress { Address = "*****@*****.**", EmailAddressType = EmailAddressTypeEnum.Work } }, PhoneNumbers = new List<PhoneNumber> { new PhoneNumber { Number = "0044 203 076 1054", PhoneNumberType = PhoneNumberTypeEnum.Home } } }; Console.WriteLine("Persisting patient..."); try { peopleService.AddPerson(person); Console.WriteLine("Patient persisted correctly"); } catch (Exception ex) { Console.WriteLine("Failure persisting patient: {0}", ex.InnerException); } Console.WriteLine("Populating: Jack Smith"); person = new Person { Title = "Mr", FirstName = "Jack", MiddleName = "", LastName = "Smith", Sex = "M", DateOfBirth = new DateTime(1969, 4, 3), Employer = "Goldman Sachs", //Qualifications = "", Occupation = "Software developer", Salutation = "Dear", PersonType = PersonTypeEnum.Patient, Addresses = new List<Address>{new Address{AddressLine1="13 Ashley Clo",AddressLine2="Killamarsh", Town="Sheffield", PostCode="S21 1AA", StateCounty="Derbyshire", Country="United Kingdom", AddressType=AddressTypeEnum.Home}}, EmailAddresses = new List<EmailAddress> { new EmailAddress { Address = "*****@*****.**", EmailAddressType = EmailAddressTypeEnum.Work }, new EmailAddress { Address = "*****@*****.**", EmailAddressType = EmailAddressTypeEnum.Private }}, PhoneNumbers = new List<PhoneNumber> { new PhoneNumber { Number = "0044 0114 248 3294", PhoneNumberType = PhoneNumberTypeEnum.Home } } }; Console.WriteLine("Persisting patient..."); try { peopleService.AddPerson(person); Console.WriteLine("Patient persisted correctly"); } catch (Exception ex) { Console.WriteLine("Failure persisting patient: {0}", ex.InnerException); } Console.WriteLine("Populating: Linda Robster"); person = new Person { Title = "Mr", FirstName = "Linda", MiddleName = "", LastName = "Robster", Sex = "F", DateOfBirth = new DateTime(1942, 8, 11), Employer = "BBC", //Qualifications = "", Occupation = "TV presenter", Salutation = "Dear", PersonType = PersonTypeEnum.Patient, Addresses = new List<Address>{new Address{AddressLine1="12 Red Square",AddressLine2="", Town="Wimbledon", PostCode="SW19 8PS", StateCounty="Greater London", Country="United Kingdom", AddressType=AddressTypeEnum.Home}}, EmailAddresses = new List<EmailAddress> { new EmailAddress { Address = "*****@*****.**", EmailAddressType = EmailAddressTypeEnum.Work }, new EmailAddress { Address = "*****@*****.**", EmailAddressType = EmailAddressTypeEnum.Private }}, PhoneNumbers = new List<PhoneNumber> { new PhoneNumber { Number = "0044 0114 556 787899", PhoneNumberType = PhoneNumberTypeEnum.Home } } }; Console.WriteLine("Persisting patient..."); try { peopleService.AddPerson(person); Console.WriteLine("Patient persisted correctly"); } catch (Exception ex) { Console.WriteLine("Failure persisting patient: {0}", ex.InnerException); } }
public void UpdatePerson(Person person) { using (var session = dbStore.OpenSession()) { var dbPerson = session.Load<Person>(person.Id); dbPerson.PopulateFromPerson(person); session.SaveChanges(); } }
public void PopulateFromPerson(Person person) { this.Title = person.Title; this.FirstName = person.FirstName; this.MiddleName = person.MiddleName; this.LastName = person.LastName; this.Sex = person.Sex; this.DateOfBirth = person.DateOfBirth; this.Occupation = person.Occupation; this.Qualifications = person.Qualifications; this.Salutation = person.Salutation; this.PersonType = person.PersonType; }
public void AddEmailAddressToPerson(EmailAddress address, Person person) { var personId = person.Id; AddEmailAddressToPerson(address, personId); }