public void AddStreet(Common.Street street) { this.Entities.Streets.Add(street); this.Entities.SaveChanges(); }
/// <summary> /// Registers a new user. /// </summary> /// <param name="User">User to be added.</param> public void RegisterPerson(Common.Person Person, string street, string property, Guid?ddLocality, Guid?ddStreet) { if (Person.IdCardNumber != null) { if (CheckRegister(Person.IdCardNumber)) { if (Person.Gender_fk == "None") { Person.Gender_fk = null; } Person.PersonID = Guid.NewGuid(); DataLayer.PatientsHandler dap = new DataLayer.PatientsHandler(); if (property == "") { this.AddPersonToDatabase(Person); } else { if (street == "") { Common.Property p = new Common.Property(); p.PropertyName = property; p.Street_fk = ddStreet; p.PropertyId = Guid.NewGuid(); dap.AddProperty(p); Person.Property_fk = p.PropertyId; this.AddPersonToDatabase(Person); } else { Common.Street s = new Common.Street(); s.StreetName = street; s.Locality_fk = ddLocality; s.StreetId = Guid.NewGuid(); dap.AddStreet(s); Common.Property p = new Common.Property(); p.PropertyName = property; p.Street_fk = s.StreetId; p.PropertyId = Guid.NewGuid(); dap.AddProperty(p); Person.Property_fk = p.PropertyId; this.AddPersonToDatabase(Person); } } } } else { if (Person.Gender_fk == "None") { Person.Gender_fk = null; } Person.PersonID = Guid.NewGuid(); DataLayer.PatientsHandler dap = new DataLayer.PatientsHandler(); if (property == "") { this.AddPersonToDatabase(Person); } else { if (street == "") { Common.Property p = new Common.Property(); p.PropertyName = property; p.Street_fk = ddStreet; p.PropertyId = Guid.NewGuid(); dap.AddProperty(p); Person.Property_fk = p.PropertyId; this.AddPersonToDatabase(Person); } else { Common.Street s = new Common.Street(); s.StreetName = street; s.Locality_fk = ddLocality; s.StreetId = Guid.NewGuid(); dap.AddStreet(s); Common.Property p = new Common.Property(); p.PropertyName = property; p.Street_fk = s.StreetId; p.PropertyId = Guid.NewGuid(); dap.AddProperty(p); Person.Property_fk = p.PropertyId; this.AddPersonToDatabase(Person); } } } }