Exemplo n.º 1
0
 public void AddProperty(Common.Property property)
 {
     this.Entities.Properties.Add(property);
     this.Entities.SaveChanges();
 }
Exemplo n.º 2
0
        /// <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);
                    }
                }
            }
        }