예제 #1
0
        /// <summary>
        /// Adds an instance to this item list.
        /// </summary>
        /// <param name="home"></param>
        public int Add(Home home)
        {
            if (home != null)
            {
                int  preCount       = this.Count;
                Home collectionHome = _homesList.SingleOrDefault(h => h.Address == home.Address &&
                                                                 h.Zip == home.Zip);

                if (collectionHome == null)
                {
                    if (LogicBroker.StoreItem <Home>(home))
                    {
                        Home storedHome = LogicBroker.GetHome(home.HomeID);

                        if (storedHome != null)
                        {
                            this._homesList.Add(storedHome);

                            if (this.Count > preCount)
                            {
                                collectionMonitor.SendNotifications(1, "Home");
                                return(1);
                            }
                        }
                    }
                }
            }

            return(0);
        }
        /// <summary>
        /// Attempts to add a RealEstateCompany instance to the Collection and the Database. Returns True if succeeds, False if otherwise.
        /// </summary>
        /// <param name="realEstateCompany"></param>
        /// <returns></returns>
        public int Add(RealEstateCompany realEstateCompany)
        {
            if (realEstateCompany != null)
            {
                int preCount = this.Count;
                RealEstateCompany collectionReco = _recoList
                                                   .SingleOrDefault(re =>
                                                                    re.CompanyName == realEstateCompany.CompanyName);

                if (collectionReco == null)
                {
                    if (LogicBroker.StoreItem <RealEstateCompany>(realEstateCompany))
                    {
                        RealEstateCompany storedReco = LogicBroker.GetReCompany(realEstateCompany.CompanyID);

                        if (storedReco != null)
                        {
                            this._recoList.Add(storedReco);

                            if (this.Count > preCount)
                            {
                                collectionMonitor.SendNotifications(1, "RECo");
                                return(1);
                            }
                        }
                    }
                }
            }

            return(0);
        }
        /// <summary>
        /// Add a HomeSale instance to this collection. Will only accept object whose MarketDate and SaleAmount members are not null
        /// and the homesale instance is not already in the collection.
        /// </summary>
        /// <param name="homeSale"></param>
        public int Add(HomeSale homeSale)
        {
            if (homeSale != null)
            {
                int      preCount           = this.Count;
                HomeSale collectionHomeSale = _homeSalesList.SingleOrDefault(hs => hs.MarketDate == homeSale.MarketDate &&
                                                                             hs.SaleAmount == homeSale.SaleAmount);

                if (collectionHomeSale == null)
                {
                    if (LogicBroker.StoreItem <HomeSale>(homeSale))
                    {
                        HomeSale storedHomeSale = LogicBroker.GetHomeSale(homeSale.SaleID);

                        if (storedHomeSale != null)
                        {
                            _homeSalesList.Add(storedHomeSale);

                            if (this.Count > preCount)
                            {
                                collectionMonitor.SendNotifications(1, "HomeSale");
                                return(1);
                            }
                        }
                    }
                }
            }

            return(0);
        }
        /// <summary>
        /// Allows caller to add a Person to the Collection based on PersonID
        /// </summary>
        /// <param name="person"></param>
        public int Add(T person)
        {
            if (person != null)
            {
                int    preCount         = this.Count;
                Person collectionPerson = _peopleList.SingleOrDefault(p =>
                                                                      p.FirstName == person.FirstName && p.LastName == person.LastName);

                if (collectionPerson == null)
                {
                    if (LogicBroker.StoreItem <Person>(person))
                    {
                        Person storedPerson = LogicBroker.GetPerson(person.PersonID);

                        if (storedPerson != null)
                        {
                            _peopleList.Add((T)storedPerson);

                            if (this.Count > preCount)
                            {
                                collectionMonitor.SendNotifications(1, "Person");
                                return(1);
                            }
                        }
                    }
                }
            }

            return(0);
        }