예제 #1
0
 public static Country CreateInfo(Data.Country country) => new Country
 {
     MobileCode  = country.MobileCode.ToString(),
     Code        = country.Code.ToString(),
     Name        = country.Name,
     PricePerSMS = Math.Round(country.PricePerSMS, 2)
 };
예제 #2
0
파일: State.cs 프로젝트: waffle-iron/nequeo
        /// <summary>
        /// Gets the state list.
        /// </summary>
        /// <param name="languageCountryCode">The language country code to search on.</param>
        /// <returns>The state list.</returns>
        public virtual Data.Extended.StateList[] GetLongNameList(string languageCountryCode)
        {
            // Create the new cache control container.
            Nequeo.Data.Control.ICacheControl selectCache = Select;

            selectCache.CacheItems     = true;
            selectCache.CachedItemName = "StateListLong" + languageCountryCode.ToString();
            selectCache.CacheTimeout   = 200;

            Data.Extended.StateList[] list = null;

            // Is the item to be cached.
            if (selectCache.CacheItems)
            {
                // Get the item from the cache.
                object item = selectCache.GetItemFromCache(selectCache.CachedItemName);
                if (item != null)
                {
                    if (item is Data.Extended.StateList[])
                    {
                        list = item as Data.Extended.StateList[];
                    }
                }
            }

            // If the item has not been cached
            // then get the items from the database.
            if (list == null)
            {
                // Get the langauge details.
                Data.Language language  = DataContext.Languages.First(l => l.LanguageCountryCode == languageCountryCode);
                Data.Country  country   = DataContext.Countries.First(c => c.CountryName == language.CountryName);
                long          countryID = country.CountryID;

                list = Select.
                       SelectIQueryableItems(s => (s.StateVisible == true) && (s.CountryID == countryID)).
                       OrderBy(s => s.GroupOrder).
                       Select(s => new
                {
                    StateID     = s.StateID,
                    StateName   = s.StateLongName,
                    StateCodeID = s.StateCodeID,
                    CountryID   = s.CountryID
                }).ToTypeArray <Data.Extended.StateList>();
            }

            // Cache the item.
            if (selectCache.CacheItems)
            {
                selectCache.AddItemToCache(selectCache.CachedItemName, selectCache.CacheTimeout, list);
            }

            return(list);
        }
        private List <Country> Deserialize_Countries(string jsonCountries)
        {
            var mapper  = Create_Mapper();
            var country = new Data.Country();

            var result = country.Deserialize_Countries(jsonCountries);

            //Should we add the mapper on the data class?
            var entity = mapper.Map <List <Country> >(result);

            return(entity);
        }
예제 #4
0
        public static async Task <Data.State> SendSMSAsync(string from, string to, string text, ISMSSender smsSender)
        {
            Data.Country country = await Data.DataProvider.IdentifyCountry(to);

            var state = Data.State.Failed;

            if (country != null)
            {
                state = await smsSender.SendSMSAsync(from, to, country.MobileCode, text);
            }

            int saved = await Data.DataProvider.AddSMSAsync(from, to, country, state, DateTime.UtcNow);

            return(saved > 0 ? state : Data.State.Failed);
        }
예제 #5
0
        public static void Register(HttpConfiguration config)
        {
            // Uncomment the following to use the documentation from XML documentation file.
            config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/bin/XmlDocument.xml")));

            var germany = new Data.Country {
                MobileCode = 262, Code = 49, Name = "Germany", PricePerSMS = 0.055m
            };
            var austria = new Data.Country {
                MobileCode = 232, Code = 43, Name = "Austria", PricePerSMS = 0.053m
            };

            var successSms = new SMS
            {
                DateTime          = GetTruncatedDate(DateTime.UtcNow.Date),
                From              = "The Sender",
                MobileCountryCode = "49",
                Price             = 0.06m,
                State             = Data.State.Success,
                To = "+4917421293388"
            };
            var failedSms = new SMS
            {
                DateTime          = GetTruncatedDate(DateTime.UtcNow),
                From              = "Goofy",
                MobileCountryCode = "",
                Price             = 0m,
                State             = Data.State.Failed,
                To = "+8800807775533"
            };

            Record germanyRecord = DataManager.CreateRecord(new Data.Record
            {
                Day     = DateTime.UtcNow.Date,
                Country = germany,
                Count   = 42
            });
            Record austriaRecord = DataManager.CreateRecord(new Data.Record
            {
                Day     = DateTime.UtcNow.Date.AddDays(-1),
                Country = austria,
                Count   = 13
            });

            config.SetSampleObjects(new Dictionary <Type, object>
            {
                {
                    typeof(List <Country>),
                    new List <Country> {
                        DataManager.CreateInfo(germany), DataManager.CreateInfo(austria)
                    }
                },
                {
                    typeof(GetSentSMSResponse),
                    new GetSentSMSResponse
                    {
                        Items = new List <SMS> {
                            successSms, failedSms
                        },
                        TotalAmount = 20
                    }
                },
                {
                    typeof(List <Record>),
                    new List <Record> {
                        germanyRecord, austriaRecord
                    }
                }
            });

            // Extend the following to provide factories for types not handled automatically (those lacking parameterless
            // constructors) or for which you prefer to use non-default property values. Line below provides a fallback
            // since automatic handling will fail and GeneratePageResult handles only a single type.
#if Handle_PageResultOfT
            config.GetHelpPageSampleGenerator().SampleObjectFactories.Add(GeneratePageResult);
#endif

            // Extend the following to use a preset object directly as the sample for all actions that support a media
            // type, regardless of the body parameter or return type. The lines below avoid display of binary content.
            // The BsonMediaTypeFormatter (if available) is not used to serialize the TextSample object.
            config.SetSampleForMediaType(
                new TextSample("Binary JSON content. See http://bsonspec.org for details."),
                new MediaTypeHeaderValue("application/bson"));

            //// Uncomment the following to use "[0]=foo&[1]=bar" directly as the sample for all actions that support form URL encoded format
            //// and have IEnumerable<string> as the body parameter or return type.
            //config.SetSampleForType("[0]=foo&[1]=bar", new MediaTypeHeaderValue("application/x-www-form-urlencoded"), typeof(IEnumerable<string>));

            //// Uncomment the following to use "1234" directly as the request sample for media type "text/plain" on the controller named "Values"
            //// and action named "Put".
            //config.SetSampleRequest("1234", new MediaTypeHeaderValue("text/plain"), "Values", "Put");

            //// Uncomment the following to use the image on "../images/aspNetHome.png" directly as the response sample for media type "image/png"
            //// on the controller named "Values" and action named "Get" with parameter "id".
            //config.SetSampleResponse(new ImageSample("../images/aspNetHome.png"), new MediaTypeHeaderValue("image/png"), "Values", "Get", "id");

            //// Uncomment the following to correct the sample request when the action expects an HttpRequestMessage with ObjectContent<string>.
            //// The sample will be generated as if the controller named "Values" and action named "Get" were having string as the body parameter.
            //config.SetActualRequestType(typeof(string), "Values", "Get");

            //// Uncomment the following to correct the sample response when the action returns an HttpResponseMessage with ObjectContent<string>.
            //// The sample will be generated as if the controller named "Values" and action named "Post" were returning a string.
            //config.SetActualResponseType(typeof(string), "Values", "Post");
        }
예제 #6
0
		private Data.Country GetData()
		{
			var c = new Data.Country
			{
				Name = "Australia",
				Regions = new List<Data.Region>{
					new Data.Region{
						Name = "Australian Capital Territories",
						ShortName = "AC",
						Weight = 3,
						Cities = new List<Data.City>{
							new Data.City{Name = "Canberra"}
						}
					},
					new Data.Region{
						Name= "New South Wales",
						ShortName= "NS",
						Weight= 69,
						Cities=new List<Data.City>{
							new Data.City{ Name = "Sydney"},
							new Data.City{ Name = "Albury"},
							new Data.City{ Name = "Armidale"},
							new Data.City{ Name = "Bathurst"},
							new Data.City{ Name = "Blue Mountains"},
							new Data.City{ Name = "Broken Hill"},
							new Data.City{ Name = "Campbelltown"},
							new Data.City{ Name = "Cessnock"},
							new Data.City{ Name = "Dubbo"},
							new Data.City{ Name = "Goulburn"},
							new Data.City{ Name = "Grafton"},
							new Data.City{ Name = "Lithgow",},
							new Data.City{ Name = "Liverpool"},
							new Data.City{ Name = "Newcastle"},
							new Data.City{ Name = "Orange"},
							new Data.City{ Name = "Parramatta"},
							new Data.City{ Name = "Penrith"},
							new Data.City{ Name = "Queanbeyan"},
							new Data.City{ Name = "Tamworth"},
							new Data.City{ Name = "Wagga Wagga"},
							new Data.City{ Name = "Wollongong"}
						}
					},
					new Data.Region{
						Name = "Northern Territory",
						ShortName = "NT",
						Weight = 2,
						Cities = new List<Data.City>{
							new Data.City{ Name = "Darwin"},
							new Data.City{ Name = "Palmerston"}
						}
					},
					new Data.Region{
						Name = "Queensland",
						ShortName = "QL",
						Weight = 42,
						Cities = new List<Data.City>{
							new Data.City{ Name = "Brisbane"},
							new Data.City{ Name = "Bundaberg"},
							new Data.City{ Name = "Cairns"},
							new Data.City{ Name = "Caloundra"},
							new Data.City{ Name = "Charters Towers"},
							new Data.City{ Name = "Gladstone"},
							new Data.City{ Name = "Gold Coast"},
							new Data.City{ Name = "Hervey Bay"},
							new Data.City{ Name = "Ipswich"},
							new Data.City{ Name = "Logan City"},
							new Data.City{ Name = "Mackay"},
							new Data.City{ Name = "Maryborough"},
							new Data.City{ Name = "Mount Isa"},
							new Data.City{ Name = "Redcliffe"},
							new Data.City{ Name = "Redlands"},
							new Data.City{ Name = "Rockhampton"},
							new Data.City{ Name = "Toowoomba"},
							new Data.City{ Name = "Townsville"}
						}
					},
					new Data.Region{
						Name = "South Australia",
						ShortName = "SA",
						Weight = 16,
						Cities = new List<Data.City>{
							new Data.City{ Name = "Adelaide"},
							new Data.City{ Name = "Mount Gambier"},
							new Data.City{ Name = "Murray Bridge"},
							new Data.City{ Name = "Port Augusta"},
							new Data.City{ Name = "Port Pirie"},
							new Data.City{ Name = "Port Lincoln"},
							new Data.City{ Name = "Victor Harbor"},
							new Data.City{ Name = "Whyalla"}
						}
					},
					new Data.Region{
						Name = "Tasmania",
						ShortName = "TA",
						Weight = 5,
						Cities = new List<Data.City>{
							new Data.City{ Name = "Greater Hobart"},
							new Data.City{ Name = "Burnie"},
							new Data.City{ Name = "Devonport"},
							new Data.City{ Name = "Launceston"}
						}
					},
					new Data.Region{
						Name = "Victoria",
						ShortName = "VI",
						Weight = 52,
						Cities = new List<Data.City>{
							new Data.City{ Name = "Melbourne"},
							new Data.City{ Name = "Ararat"},
							new Data.City{ Name = "Bairnsdale"},
							new Data.City{ Name = "Benalla"},
							new Data.City{ Name = "Ballarat"},
							new Data.City{ Name = "Bendigo"},
							new Data.City{ Name = "Belgrave"},
							new Data.City{ Name = "Dandenong"},
							new Data.City{ Name = "Frankston"},
							new Data.City{ Name = "Geelong"},
							new Data.City{ Name = "Hamilton"},
							new Data.City{ Name = "Horsham"},
							new Data.City{ Name = "Melton"},
							new Data.City{ Name = "Moe"},
							new Data.City{ Name = "Morwell"},
							new Data.City{ Name = "Mildura"},
							new Data.City{ Name = "Sale"},
							new Data.City{ Name = "Shepparton"},
							new Data.City{ Name = "Swan Hill"},
							new Data.City{ Name = "Traralgon"},
							new Data.City{ Name = "Wangaratta"},
							new Data.City{ Name = "Warrnambool"},
							new Data.City{ Name = "Wodonga"}
						}
					},
					new Data.Region{
						Name = "Western Australia",
						ShortName = "WA",
						Weight = 21,
						Cities = new List<Data.City>{
							new Data.City{ Name = "Perth"},
							new Data.City{ Name = "Albany"},
							new Data.City{ Name = "Armadale"},
							new Data.City{ Name = "Bayswater"},
							new Data.City{ Name = "Belmont"},
							new Data.City{ Name = "Bunbury"},
							new Data.City{ Name = "Canning"},
							new Data.City{ Name = "Cockburn"},
							new Data.City{ Name = "Fremantle"},
							new Data.City{ Name = "Geraldton-Greenough"},
							new Data.City{ Name = "Gosnells"},
							new Data.City{ Name =  "Joondalup"},
							new Data.City{ Name = "Kalgoorlie-Boulder"},
							new Data.City{ Name = "Mandurah"},
							new Data.City{ Name = "Melville"},
							new Data.City{ Name = "Nedlands"},
							new Data.City{ Name = "Rockingham"},
							new Data.City{ Name = "South Perth"},
							new Data.City{ Name = "Stirling"},
							new Data.City{ Name = "Subiaco"},
							new Data.City{ Name = "Swan"},
							new Data.City{ Name = "Wanneroo"}
						}
					}
				}
			};

			return c;
		}
예제 #7
0
		private Data.Country GetData()
		{
			var c = new Data.Country
			{
				Name = "Austria",
				Regions = new List<Data.Region>
				{ 
					new Data.Region
					{
						Name = "Vienna",
						ShortName = "Wien",
						Weight = 4113,
						Cities = new List<Data.City>
						{
							new Data.City { Name ="Vienna"}
						}
					},
					new Data.Region
					{
						Name = "Vorarlberg",
						ShortName = "Vbg.",
						Weight = 142,
						Cities = new List<Data.City>
						{
							new Data.City { Name = "Dornbirn"},
							new Data.City { Name = "Feldkirch"},
							new Data.City { Name = "Bregenz"},
							new Data.City { Name = "Lustenau"},
							new Data.City { Name = "Hohenems"},
							new Data.City { Name =  "Bludenz"},
							new Data.City { Name = "Hard"},
							new Data.City { Name = "Rankweil"},
							new Data.City { Name = "Götzis"},
							new Data.City { Name = "Lauterach"},
							new Data.City { Name = "Wolfurt"},
							new Data.City { Name = "Höchst"},
							new Data.City { Name = "Altach"}
						}
					},
					new Data.Region
					{
						Name ="Upper Austria",
						ShortName = "OÖ.",
						Weight = 117,
						Cities = new List<Data.City>{
							new Data.City { Name ="Linz"},
							new Data.City { Name = "Wels"},
							new Data.City { Name = "Steyr"},
							new Data.City { Name = "Leonding"},
							new Data.City { Name = "Traun"},
							new Data.City { Name = "Braunau am Inn"},
							new Data.City { Name = "Ansfelden"},
							new Data.City { Name = "Bad Ischl"},
							new Data.City { Name = "Gmunden"},
							new Data.City { Name = "Marchtrenk"},
							new Data.City { Name = "Vöcklabruck"},
							new Data.City { Name = "Ried im Innkreis"},
							new Data.City { Name = "Enns"},
							new Data.City { Name = "Altmünster"},
							new Data.City { Name = "Laakirchen"},
							new Data.City { Name = "Sierning"}
						}
					},
					new Data.Region
					{
						Name = "Lower Austria",
						ShortName = "NÖ.",
						Weight = 84,
						Cities = new List<Data.City>{
							new Data.City { Name ="St. Pölten"},
							new Data.City { Name = "Wiener Neustadt"},
							new Data.City { Name = "Klosterneuburg"},
							new Data.City { Name = "Baden"},
							new Data.City { Name = "Krems an der Donau"},
							new Data.City { Name = "Amstetten"},
							new Data.City { Name = "Mödling"},
							new Data.City { Name = "Traiskirchen"},
							new Data.City { Name = "Schwechat"},
							new Data.City { Name = "Stockerau"},
							new Data.City { Name = "Tulln an der Donau"},
							new Data.City { Name = "Ternitz"},
							new Data.City { Name = "Perchtoldsdorf"},
							new Data.City { Name = "Korneuburg"},
							new Data.City { Name = "Neunkirchen"},
							new Data.City { Name = "Hollabrunn"},
							new Data.City { Name = "Waidhofen an der Ybbs"},
							new Data.City { Name = "Bad Vöslau"},
							new Data.City { Name = "Brunn am Gebirge"},
							new Data.City { Name = "Zwettl-Niederösterreich"}
						}
					},
					new Data.Region
					{
						Name = "Salzburg",
						ShortName = "Sbg.",
						Weight = 74,
						Cities = new List<Data.City>{
							new Data.City { Name ="Salzburg"},
							new Data.City { Name = "Hallein"},
							new Data.City { Name = "Saalfelden am Steinernen Meer"},
							new Data.City { Name = "Wals-Siezenheim"},
							new Data.City { Name = "Sankt Johann im Pongau"},
							new Data.City { Name = "Bischofshofen"}
						}
					},
					new Data.Region
					{
						Name = "Styria",
						ShortName = "Stm.",
						Weight = 73,
						Cities = new List<Data.City>{
							new Data.City { Name ="Graz"},
							new Data.City { Name = "Leoben"},
							new Data.City { Name = "Kapfenberg"},
							new Data.City { Name = "Bruck an der Mur"},
							new Data.City { Name =  "Knittelfeld"},
							new Data.City { Name = "Köflach"},
							new Data.City { Name = "Voitsberg"},
							new Data.City { Name = "Judenburg"},
							new Data.City { Name = "Weiz"}
						}
					},
					new Data.Region
					{
						Name = "Burgenland",
						ShortName = "Bgl.",
						Weight = 72,
						Cities = new List<Data.City>{
							new Data.City { Name ="Eisenstadt"},
							new Data.City { Name = "Oberwart"},
							new Data.City { Name = "Neusiedl am See"},
							new Data.City { Name = "Mattersburg"},
							new Data.City { Name = "Pinkafeld"},
							new Data.City { Name = "Neudörfl"},
							new Data.City { Name = "Parndorf"},
							new Data.City { Name = "Jennersdorf"},
							new Data.City { Name = "Güssing"},
							new Data.City { Name = "Gols"},
							new Data.City { Name = "Großpetersdorf"},
							new Data.City { Name = "Neufeld an der Leitha"},
							new Data.City { Name = "Deutschkreutz"},
							new Data.City { Name = "Rechnitz"},
							new Data.City { Name = "Oberpullendorf"},
							new Data.City { Name = "Siegendorf"},
							new Data.City { Name = "Pöttsching"},
							new Data.City { Name = "Bruckneudorf"},
							new Data.City { Name =  "Frauenkirchen"},
							new Data.City { Name = "Forchtenstein"}
						}
					},
					new Data.Region
					{
						Name = "Carinthia",
						ShortName = "Ktn.",
						Weight = 59,
						Cities = new List<Data.City>{
							new Data.City { Name ="Klagenfurt"},
							new Data.City { Name = "Villach"},
							new Data.City { Name = "Wolfsberg"},
							new Data.City { Name = "Spittal an der Drau"},
							new Data.City { Name = "Feldkirchen in Kärnten"},
							new Data.City { Name = "St. Veit an der Glan"},
							new Data.City { Name = "Völkermarkt"},
							new Data.City { Name = "St. Andrä"},
							new Data.City { Name = "Velden am Wörther See"},
							new Data.City { Name = "Finkenstein am Faaker See"},
							new Data.City { Name = "Ebenthal in Kärnten"},
							new Data.City { Name = "Ferlach"}
						}
					},
					new Data.Region
					{
						Name = "Tyrol",
						ShortName = "Tirol",
						Weight = 56,
						Cities = new List<Data.City>{
							new Data.City { Name = "Innsbruck"},
							new Data.City { Name =  "Kufstein"},
							new Data.City { Name = "Telfs"},
							new Data.City { Name = "Schwaz"},
							new Data.City { Name = "Hall in Tirol"},
							new Data.City { Name = "Wörgl"},
							new Data.City { Name = "Lienz"},
							new Data.City { Name = "Imst"},
							new Data.City { Name = "Rum"},
							new Data.City { Name = "St. Johann in Tirol"},
							new Data.City { Name = "Kitzbühel"},
							new Data.City { Name = "Zirl"},
							new Data.City { Name = "Landeck"}
						}
					}
				}
			};

			return c;
		}
예제 #8
0
        private List <Domain.Country> Deserialize_Countries(string jsonCountries)
        {
            var country = new Data.Country();

            return(country.Deserialize_Countries(jsonCountries));
        }