public void Add()
        {
            var newEntity = new BusinessEntity()
            {
                Deleted     = false,
                Description = "",
                BusinessId  = -1
            };

            BusinessList.Add(newEntity);
            BusinessList = new List <BusinessEntity>(_businessList);
        }
		private static BusinessList<IPollOption> CreateOptions()
		{
			var generator = new RandomObjectGenerator();
			var optionId = generator.Generate<int>();
			var optionPosition = generator.Generate<short>();
			var optionText = generator.Generate<string>();

			var option = new Mock<IPollOption>(MockBehavior.Loose);
			option.Setup(_ => _.IsChild).Returns(true);
			option.Setup(_ => _.PollOptionID).Returns(optionId);
			option.Setup(_ => _.OptionPosition).Returns(optionPosition);
			option.Setup(_ => _.OptionText).Returns(optionText);

			var options = new BusinessList<IPollOption>();
			options.Add(option.Object);

			return options;
		}
Beispiel #3
0
        private static BusinessList <IPollOption> CreateOptions()
        {
            var generator      = new RandomObjectGenerator();
            var optionId       = generator.Generate <int>();
            var optionPosition = generator.Generate <short>();
            var optionText     = generator.Generate <string>();

            var option = new Mock <IPollOption>(MockBehavior.Loose);

            option.Setup(_ => _.IsChild).Returns(true);
            option.Setup(_ => _.PollOptionID).Returns(optionId);
            option.Setup(_ => _.OptionPosition).Returns(optionPosition);
            option.Setup(_ => _.OptionText).Returns(optionText);

            var options = new BusinessList <IPollOption>();

            options.Add(option.Object);

            return(options);
        }
        /// <summary>
        /// Parses the data in the CRRD Database XML file into the Business and Category classes.
        /// </summary>
        private void SetBusinessList()
        {
            // Collect all Elements (business) and all its descendants.
            var businesses = from qry in xDoc.Descendants("business")
                             select new
            {
                // string values
                Name = qry.Element("name").Value,
            };

            Business tmpBus;


            // Fill the Business and Category objects with the gathered XML data
            foreach (var bus in businesses)
            {
                tmpBus      = new Business();
                tmpBus.Name = bus.Name;
                BusinessList.Add(tmpBus);
            }
        }
        /// <summary>
        /// Parses the data in the CRRD Database XML file into the Business and Category classes
        /// </summary>
        protected void SetBusinessList()
        {
            // Collect all Elements (business) and all its decendants
            var businesses = from qry in xDoc.Descendants("business")
                             select new
            {
                // string values
                Name    = qry.Element("name").Value,
                Addr1   = qry.Element("contact_info").Element("address").Element("address_line_1").Value,
                Addr2   = qry.Element("contact_info").Element("address").Element("address_line_2").Value,
                City    = qry.Element("contact_info").Element("address").Element("city").Value,
                State   = qry.Element("contact_info").Element("address").Element("state").Value,
                Phone   = qry.Element("contact_info").Element("phone").Value,
                Website = qry.Element("contact_info").Element("website").Value,

                // collection values
                Categories = qry.Element("category_list").Elements("category"),
                Links      = qry.Element("link_list").Elements("link"),

                // int & double values
                ID  = qry.Element("id").Value,
                Zip = (qry.Element("contact_info").Element("address").Element("zip").Value != "")
                                                ? qry.Element("contact_info").Element("address").Element("zip").Value : "0",
                Lat = (qry.Element("contact_info").Element("latlong").Element("latitude").Value != "")
                                                ? qry.Element("contact_info").Element("latlong").Element("latitude").Value : "0",
                Lng = (qry.Element("contact_info").Element("latlong").Element("longitude").Value != "")
                                                ? qry.Element("contact_info").Element("latlong").Element("longitude").Value : "0"
            };


            Business        tmpBus;
            List <Category> tmpCatList;
            List <Link>     tmpLinkList;

            string tmpLinkName;
            string tmpLinkURI;

            // Fill the Business and Category objects with the gathered XML data
            foreach (var bus in businesses)
            {
                tmpBus      = new Business();
                tmpCatList  = new List <Category>();
                tmpLinkList = new List <Link>();

                tmpBus.Name        = bus.Name;
                tmpBus.Address_1   = bus.Addr1;
                tmpBus.Address_2   = bus.Addr2;
                tmpBus.City        = bus.City;
                tmpBus.State       = bus.State;
                tmpBus.Phone       = bus.Phone;
                tmpBus.Website     = bus.Website;
                tmpBus.Database_ID = Int32.Parse(bus.ID);
                tmpBus.Zip         = Int32.Parse(bus.Zip);
                tmpBus.Latitude    = double.Parse(bus.Lat);
                tmpBus.Longitude   = double.Parse(bus.Lng);

                // Process for Subcategory Lists
                foreach (var c in bus.Categories)
                {
                    var subcategories = from qry in c.Descendants("subcategory")
                                        select new
                    {
                        Subcat = qry.Value
                    };


                    List <string> tmpSubList = new List <string>();
                    foreach (var s in subcategories)
                    {
                        tmpSubList.Add(s.Subcat);
                    }

                    tmpCatList.Add(new Category(c.Element("name").Value, tmpSubList));
                }
                tmpBus.CategoryList = tmpCatList;

                // Process for Link Lists
                foreach (var l in bus.Links)
                {
                    tmpLinkName = l.Element("name").Value;
                    tmpLinkURI  = l.Element("URI").Value;

                    tmpLinkList.Add(new Link(tmpLinkName, tmpLinkURI));
                }
                tmpBus.LinkList = tmpLinkList;

                BusinessList.Add(tmpBus);
            }
        }