/// <summary>
        /// Fill method for populating an entire collection of Residences
        /// </summary>
        public virtual void Fill(Residences residences)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(Residence.GetConnectionString());


            try
            {
                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectResidences");


                    // Send the collection and data to the object factory
                    CreateObjectsFromData(residences, datareader);


                    // close the connection
                    cnn.Close();
                }


                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(Residences residences, System.Data.DataSet data)
        {
            // Do nothing if we have nothing
            if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0)
            {
                return;
            }


            // Create a local variable for the new instance.
            Residence newobj = null;

            // Create a local variable for the data row instance.
            System.Data.DataRow dr = null;


            // Iterate through the table rows
            for (int i = 0; i < data.Tables[0].Rows.Count; i++)
            {
                // Get a reference to the data row
                dr = data.Tables[0].Rows[i];
                // Create a new object instance
                newobj = System.Activator.CreateInstance(residences.ContainsType[0]) as Residence;
                // Let the instance set its own members
                newobj.SetMembers(ref dr);
                // Add the new object to the collection instance
                residences.Add(newobj);
            }
        }
Esempio n. 3
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     rentals    = new Rentals();
     residences = new Residences();
     tenants    = new Tenants();
     PopulateResidences();
 }
    /// <summary>
    /// Instantiate Residence Node, with the given parameters. If no TiledArea is specified, a new TiledArea is created and added to the region. Default rotation is identity. See overload including rotation
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="residencePrefab"></param>
    /// <param name="position"></param>
    /// <param name="rotation"></param>
    /// <param name="parentTiledArea"></param>
    /// <param name="residenceName"></param>
    /// <returns></returns>
    public T CreateResidence <T>(GameObject residencePrefab, Vector3 position, Quaternion rotation, TiledArea parentTiledArea = null, string residenceName = "defaultResidence") where T : MonoBehaviour, INode, IResidence, IArea
    {
        GameObject newResidence = Instantiate(residencePrefab, position, rotation);

        UtilityFunctions.PutObjectOnGround(newResidence.transform);

        T residenceNode = newResidence.AddComponent <T>();

        residenceNode.SetUp(residenceName);
        residenceNode.transform.parent = transform;

        residenceNode.SetUpResidence(this, new List <INode>());
        // TODO: Generalise hut dimensions using data of the hut prefab itself
        residenceNode.SetUpArea(residenceNode.transform, hutDimensions);
        AddLink(residenceNode);
        Residences.Add(residenceNode);
        Areas.Add(residenceNode);
        VillageData.SetHutCount(VillageData.HutCount + 1);
        // If tiled area was not provided, then create a new one
        if (parentTiledArea is null)
        {
            var newTiledArea = new TiledArea(residenceNode);
            TiledAreas.Add(newTiledArea);
        }
        else
        {
            parentTiledArea.AddArea(residenceNode);
        }

        return(residenceNode);
    }
Esempio n. 5
0
        /// <summary>
        /// Gets the objects for the RESIDENCE relationship.
        /// </summary>
        public Residences GetResidences()
        {
            Residences residences = new Residences();


            ResidenceBase.ServiceObject.FillByBorrowerResidencyType(residences, _id);
            return(residences);
        }
        private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
        {
            var data = DataService.GetAllDistinctResidencesAsync().Result;

            foreach (var item in data)
            {
                Residences.Add(item);
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            residences = new Residences();
            rentals    = new Rentals();
            tenants    = new Tenants();

            lstResidences.ItemsSource = residences.AllResidences;
            allRentals = rentals.AllRentals;
        }
 public void AddResidence(Residence r)
 {
     if (Residences == null)
     {
         Residences = new List <Residence>();
     }
     if (!Residences.Contains(r))
     {
         Residences.Add(r);
     }
 }
 public void SetResidences(List <Residence> r)
 {
     if (Residences == null)
     {
         Residences = new List <Residence>();
     }
     foreach (Residence rs in r)
     {
         Residences.Add(rs);
     }
 }
Esempio n. 10
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            RentalContract = await _context.RentalContract.FirstOrDefaultAsync(m => m.RentalContractId == id);

            if (RentalContract == null)
            {
                return(NotFound());
            }

            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Unknown", Value = "Unknown"
            });
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Single", Value = "Single"
            });
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Widdow", Value = "Widdow"
            });
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Married", Value = "Married"
            });
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Divorced", Value = "Divorced"
            });
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Separated", Value = "Separated"
            });

            ViewData["MaritalStatus"] = MaritalsStatus;

            foreach (Employee staff in _context.Employee.ToList())
            {
                StaffMembers.Add(staff.EmployeeId, staff.Identification); // new SelectListItem() { Text = staff.Identification, Value = staff.Identification });
            }

            foreach (Apartment aprt in _context.Apartment.ToList())
            {
                Residences.Add(aprt.ApartmentId, aprt.Residence);
            }

            return(Page());
        }
        /// <summary>
        /// Gets all the available objects.
        /// </summary>
        public virtual Residences GetAll()
        {
            // create a new instance of the return object
            Residences objects = new Residences();


            // fill the objects
            this.Fill(objects);


            // return the filled object from the service
            return(objects);
        }
        /// <summary>
        /// Fill method for populating a collection by BORROWER
        /// </summary>
        public void FillByBorrower(Residences residences, System.Int64 id)
        {
            // create the connection to use
            SqlConnection cnn = new SqlConnection(Residence.GetConnectionString());


            try
            {
                // discover the sql parameters
                SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(Residence.GetConnectionString(), "gsp_SelectResidencesByBorrower");


                using (cnn)
                {
                    // open the connection
                    cnn.Open();


                    // set the parameters
                    sqlparams["@borrowerId"].Value = id;


                    // create an instance of the reader to fill.
                    SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectResidencesByBorrower", sqlparams);


                    // Send the collection and data to the object factory.
                    CreateObjectsFromData(residences, datareader);


                    // close the connection
                    cnn.Close();
                }


                // nullify the connection
                cnn = null;
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
        }
Esempio n. 13
0
        public IActionResult OnGet()
        {
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Unknown", Value = "Unknown"
            });
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Single", Value = "Single"
            });
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Widdow", Value = "Widdow"
            });
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Married", Value = "Married"
            });
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Divorced", Value = "Divorced"
            });
            MaritalsStatus.Add(new SelectListItem()
            {
                Text = "Separated", Value = "Separated"
            });

            ViewData["MaritalStatus"] = MaritalsStatus;

            foreach (Employee staff in _context.Employee.ToList())
            {
                StaffMembers.Add(staff.EmployeeId, staff.Identification);
            }

            foreach (Apartment aprt in _context.Apartment.ToList())
            {
                Residences.Add(aprt.ApartmentId, aprt.Residence);
            }

            return(Page());
        }
        /// <summary>
        /// The object factory for a particular data collection instance.
        /// </summary>
        public virtual void CreateObjectsFromData(Residences residences, System.Data.SqlClient.SqlDataReader data)
        {
            // Do nothing if we have nothing
            if (data == null)
            {
                return;
            }


            // Create a local variable for the new instance.
            Residence newobj = null;

            // Iterate through the data reader
            while (data.Read())
            {
                // Create a new object instance
                newobj = System.Activator.CreateInstance(residences.ContainsType[0]) as Residence;
                // Let the instance set its own members
                newobj.SetMembers(ref data);
                // Add the new object to the collection instance
                residences.Add(newobj);
            }
        }