コード例 #1
0
        public static bool FlushHomeSalesTableToXml()
        {
            bool done = false;

            using (var context = new HSTDataModel())
            {
                var homesalesList = context.HomeSales.OrderBy(hs => hs.SaleID).ToList();
                var xDocument     = new XDocument(
                    new XDeclaration(xDeclaration),
                    new XElement("HomeSales",
                                 from hs in homesalesList
                                 select new XElement("HomeSale",
                                                     new XElement("SaleID", hs.SaleID),
                                                     new XElement("HomeID", hs.HomeID),
                                                     new XElement("SoldDate", hs.SoldDate),
                                                     new XElement("AgentID", hs.AgentID),
                                                     new XElement("SaleAmount", hs.SaleAmount),
                                                     new XElement("BuyerID", hs.BuyerID),
                                                     new XElement("MarketDate", hs.MarketDate),
                                                     new XElement("CompanyID", hs.CompanyID)
                                                     )));
                string filename = "HomeSales.xml";
                done = FilesHelper.WriteOutXmlFiles(xDocument, filename);
            }
            return(done);
        }
コード例 #2
0
        /// <summary>
        /// Owner has a collection of Homes
        /// </summary>
        /// <returns></returns>
        public static List <Owner> GetTreeListOfOwners()
        {
            List <Owner> ownerList = null;

            using (HSTDataModel context = new HSTDataModel())
            {
                foreach (var owner in context.Owners.Include(h => h.Homes)
                         .Include(p => p.Person))
                {
                    ownerList.Add(owner);
                }
            }
            return(ownerList);
        }
コード例 #3
0
        /// <summary>
        /// Agent has a collection of HomeSales
        /// </summary>
        /// <returns></returns>
        public static List <Agent> GetTreeListOfAgents()
        {
            var agentList = default(List <Agent>);

            using (HSTDataModel context = new HSTDataModel())
            {
                foreach (var agent in context.Agents.Include(p => p.Person)
                         .Include(r => r.RealEstateCompany)
                         .Include(a => a.HomeSales))
                {
                    agentList.Add(agent);
                }
            }
            return(agentList);
        }
コード例 #4
0
        /// <summary>
        /// RealEstateCompany has a collection of Agents and HomeSales
        /// </summary>
        /// <returns></returns>
        public static List <RealEstateCompany> GetTreeListOfRECompanies()
        {
            var recosList = default(List <RealEstateCompany>);   //  allows using var, forces null if nullable type

            using (var context = new HSTDataModel())
            {
                recosList = new List <RealEstateCompany>();
                foreach (var reco in context.RealEstateCompanies.Include(hs => hs.HomeSales)
                         .Include(a => a.Agents))
                {
                    recosList.Add(reco);
                }
            }
            return(recosList);
        }
コード例 #5
0
        /// <summary>
        /// Home has a collection of HomeSales
        /// </summary>
        /// <returns></returns>
        public static List <Home> GetTreeListOfHomes()
        {
            List <Home> homesList = null;

            using (HSTDataModel context = new HSTDataModel())
            {
                homesList = new List <Home>();
                foreach (Home home in context.Homes.Include(hs => hs.HomeSales)
                         .Include(o => o.Owner))
                {
                    homesList.Add(home);
                }
            }
            return(homesList);
        }
コード例 #6
0
        /// <summary>
        /// Buyer has a collection of HomeSales
        /// </summary>
        /// <returns></returns>
        public static List <Buyer> GetTreeListOfBuyers()
        {
            var buyersList = default(List <Buyer>);

            using (var context = new HSTDataModel())
            {
                buyersList = new List <Buyer>();
                foreach (var buyer in context.Buyers.Include(p => p.Person)
                         .Include(b => b.HomeSales))
                {
                    buyersList.Add(buyer);
                }
            }
            return(buyersList);
        }
コード例 #7
0
        /// <summary>
        /// A Person is the parent model for Agents, Buyers, and Owners, who contain PersonID reference pointers.
        /// </summary>
        /// <returns></returns>
        public static List <Person> GetListOfPeople()
        {
            List <Person> peopleList = null;

            using (HSTDataModel context = new HSTDataModel())
            {
                peopleList = new List <Person>();
                foreach (Person person in context.People.Include(o => o.Owner)
                         .Include(a => a.Agent)
                         .Include(b => b.Buyer))
                {
                    peopleList.Add(person);
                }
            }
            return(peopleList);
        }
コード例 #8
0
        /// <summary>
        /// HomeSale does not contain any collection of other entities
        /// </summary>
        /// <returns></returns>
        public static List <HomeSale> GetListOfHomeSales()
        {
            List <HomeSale> homeSalesList = null;

            using (HSTDataModel context = new HSTDataModel())
            {
                homeSalesList = new List <HomeSale>();
                foreach (HomeSale homesale in context.HomeSales.Include(hs => hs.Agent)
                         .Include(a => a.RealEstateCompany)
                         .Include(b => b.Buyer)
                         .Include(h => h.Home))
                {
                    homeSalesList.Add(homesale);
                }
            }
            return(homeSalesList);
        }
コード例 #9
0
        /// <summary>
        /// Flush Owners entities to an XDocument and write it to file
        /// </summary>
        /// <returns></returns>
        public static bool FlushOwnersTableToXml()
        {
            bool done = false;

            using (var context = new HSTDataModel())
            {
                var ownersList = context.Owners.OrderBy(o => o.OwnerID).ToList();
                var xDocument  = new XDocument(
                    new XDeclaration(xDeclaration),
                    new XElement("Owners",
                                 from o in ownersList
                                 select new XElement("Owner",
                                                     new XElement("OwnerID", o.OwnerID),
                                                     new XElement("PreferredLender", o.PreferredLender)
                                                     )));
                string filename = "Owners.xml";
                done = FilesHelper.WriteOutXmlFiles(xDocument, filename);
            }
            return(done);
        }
コード例 #10
0
        public static bool FlushBuyersTableToXml()
        {
            bool done = false;

            using (var context = new HSTDataModel())
            {
                var buyersList = context.Buyers.OrderBy(b => b.BuyerID).ToList();
                var xDocument  = new XDocument(
                    new XDeclaration(xDeclaration),
                    new XElement("Buyers",
                                 from b in buyersList
                                 select new XElement("Buyer",
                                                     new XElement("BuyerID", b.BuyerID),
                                                     new XElement("CreditRating", b.CreditRating)
                                                     )));
                string filename = "Buyers.xml";
                done = FilesHelper.WriteOutXmlFiles(xDocument, filename);
            }
            return(done);
        }
コード例 #11
0
        public static bool FlushRealEstateCompaniesTableToXml()
        {
            bool done = false;

            using (var context = new HSTDataModel())
            {
                var reCosList = context.RealEstateCompanies.OrderBy(re => re.CompanyID).ToList();
                var xDocument = new XDocument(
                    new XDeclaration(xDeclaration),
                    new XElement("RealEstateCommpanies",
                                 from re in reCosList
                                 select new XElement("RealEstateCompany",
                                                     new XElement("CompanyID", re.CompanyID),
                                                     new XElement("CompanyName", re.CompanyName),
                                                     new XElement("Phone", re.Phone)
                                                     )));
                string filename = "RealEstateCompanies.xml";
                done = FilesHelper.WriteOutXmlFiles(xDocument, filename);
            }
            return(done);
        }
コード例 #12
0
        public static bool FlushAgentsTableToXml()
        {
            bool done = false;

            using (var context = new HSTDataModel())
            {
                var agentsList = context.Agents.OrderBy(a => a.AgentID).ToList();
                var xDocument  = new XDocument(
                    new XDeclaration(xDeclaration),
                    new XElement("Agents",
                                 from a in agentsList
                                 select new XElement("Agent",
                                                     new XElement("AgentID", a.AgentID),
                                                     new XElement("CompanyID", a.CompanyID),
                                                     new XElement("CommissionPercent", a.CommissionPercent)
                                                     )));
                string filename = "Agents.xml";
                done = FilesHelper.WriteOutXmlFiles(xDocument, filename);
            }
            return(done);
        }
コード例 #13
0
        public static bool FlushHomesTableToXml()
        {
            bool done = false;

            using (var context = new HSTDataModel())
            {
                var homesList = context.Homes.OrderBy(h => h.HomeID).ToList();
                var xDocument = new XDocument(
                    new XDeclaration(xDeclaration),
                    new XElement("Homes",
                                 from h in homesList
                                 select new XElement("Home",
                                                     new XElement("HomeID", h.HomeID),
                                                     new XElement("Address", h.Address),
                                                     new XElement("City", h.City),
                                                     new XElement("State", h.State),
                                                     new XElement("Zip", h.Zip),
                                                     new XElement("OwnerID", h.OwnerID)
                                                     )));
                string filename = "Homes.xml";
                done = FilesHelper.WriteOutXmlFiles(xDocument, filename);
            }
            return(done);
        }
コード例 #14
0
        /// <summary>
        /// Flush People entities to an XDocument and write it to file
        /// </summary>
        /// <returns></returns>
        public static bool FlushPeopleTableToXml()
        {
            bool done = false;

            using (var context = new HSTDataModel())
            {
                //var peopleList = EntityLists.GetListOfPeople();
                var peopleList = context.People.OrderBy(p => p.PersonID).ToList();
                var xDocument  = new XDocument(
                    new XDeclaration(xDeclaration),
                    new XElement("People",
                                 from p in peopleList
                                 select new XElement("Person",
                                                     new XElement("PersonID", p.PersonID),
                                                     new XElement("FirstName", p.FirstName),
                                                     new XElement("LastName", p.LastName),
                                                     new XElement("Phone", p.Phone),
                                                     new XElement("Email", p.Email)
                                                     )));
                string filename = "People.xml";
                done = FilesHelper.WriteOutXmlFiles(xDocument, filename);
            }
            return(done);
        }