Example #1
0
        public void WriteCountryData()
        {
            var                 myCountries    = File.ReadAllText(@"Country.json");
            JObject             countries      = JObject.Parse(myCountries);
            JArray              countriesArray = (JArray)countries["results"];
            IList <CountryRead> countriesList  = countriesArray.ToObject <IList <CountryRead> >();

            for (int i = 0; i < countriesList.Count; i++)
            {
                CountryDTM c = new CountryDTM();
                c.Code        = countriesList[i].code;
                c.Name        = countriesList[i].name;
                c.Native      = countriesList[i].native;
                c.PhonePrefix = countriesList[i].phone;
                c.Capital     = countriesList[i].capital;
                c.Currency_   = countriesList[i].currency;
                c.Emoji       = countriesList[i].emoji;
                c.EmojiU      = countriesList[i].emojiU;

                CountriesListDtm.Add(c);
            }

            //Timezone
            var            myZones    = File.ReadAllText(@"Timezone_Time_Zones_Dataset.json");
            JObject        zones      = JObject.Parse(myZones);
            JArray         zonesArray = (JArray)zones["results"];
            IList <TZRead> zonesList  = zonesArray.ToObject <IList <TZRead> >();

            for (int i = 0; i < zonesList.Count; i++)
            {
                Time_zoneDTM t = new Time_zoneDTM();
                t.Zone           = zonesList[i].TimeZone;
                t.CountryCode    = zonesList[i].CountryCode;
                t.UTC_Jan_1_2020 = zonesList[i].UTC_Jan_1_2020;
                t.DST_Jul_1_2020 = zonesList[i].DST_Jul_1_2020;

                ZonesListDtm.Add(t);
            }

            //Currencies
            List <string> tempList = new List <string>();

            foreach (CountryDTM c in CountriesListDtm)
            {
                if (!tempList.Contains(c.Currency_) && c.Currency_ != "")
                {
                    tempList.Add(c.Currency_);
                }
            }
            foreach (var curLine in tempList)
            {
                CurrencyDTM cur = new CurrencyDTM();
                cur.Name = curLine;
                CurrenciesLidtDtm.Add(cur);
            }
        }
Example #2
0
        // POST: api/Countries/countryDtm
        public async Task <HttpResponseMessage> Post([FromBody] CountryDTM countryDtm)
        {
            try
            {
                int id = await TheRepo.CountriesDTM.Create(countryDtm);

                return(Request.CreateResponse(HttpStatusCode.Created, id));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Example #3
0
        public static BusinessDTM changeToDTM(Business business)
        {
            BusinessDTM bDtm = new BusinessDTM();

            bDtm.Id                 = business.Id;
            bDtm.Name               = business.Name;
            bDtm.Phone              = business.Phone;
            bDtm.Logo               = business.Logo;
            bDtm.Webpage            = business.Webpage;
            bDtm.Address            = business.Address;
            bDtm.City               = business.City;
            bDtm.State              = business.State;
            bDtm.ZipCode            = business.ZipCode;
            bDtm.RegistrationNumber = business.RegistrationNumber;

            if (business.Country != null)
            {
                CountryDTM country = new CountryDTM();
                country.Id          = business.Country.Id;
                country.Code        = business.Country.Code;
                country.Name        = business.Country.Name;
                country.Native      = business.Country.Native;
                country.PhonePrefix = business.Country.PhonePrefix;
                country.Capital     = business.Country.Capital;
                country.Currency_   = business.Country.Currency_;
                country.Emoji       = business.Country.Emoji;
                country.EmojiU      = business.Country.EmojiU;
                bDtm.Country        = country;
                bDtm.CountryId      = business.Country.Id;
            }
            if (business.Currency != null)
            {
                CurrencyDTM currency = new CurrencyDTM();
                currency.Id     = business.Currency.Id;
                currency.Name   = business.Currency.Name;
                bDtm.Currency   = currency;
                bDtm.CurrencyId = business.Currency.Id;
            }
            if (business.Time_zone != null)
            {
                Time_zoneDTM tz = new Time_zoneDTM();
                tz.Id             = business.Time_zone.Id;
                tz.Zone           = business.Time_zone.Zone;
                tz.CountryCode    = business.Time_zone.CountryCode;
                tz.UTC_Jan_1_2020 = business.Time_zone.UTC_Jan_1_2020;
                tz.DST_Jul_1_2020 = business.Time_zone.DST_Jul_1_2020;
                bDtm.Time_zone    = tz;
                bDtm.Time_zoneId  = business.Time_zone.Id;
            }
            return(bDtm);
        }
Example #4
0
        public static UserDTM changeToDTM(User user)
        {
            UserDTM userDtm = new UserDTM();

            userDtm.Id               = user.Id;
            userDtm.Email            = user.Email;
            userDtm.FirstName        = user.FirstName;
            userDtm.SecondName       = user.SecondName;
            userDtm.PhoneMobile      = user.PhoneMobile;
            userDtm.PhoneOffice      = user.PhoneOffice;
            userDtm.UserPicture      = user.UserPicture;
            userDtm.Address          = user.Address;
            userDtm.City             = user.City;
            userDtm.State            = user.State;
            userDtm.ZipCode          = user.ZipCode;
            userDtm.PlanId           = user.PlanId;
            userDtm.IsPaymentOverdue = user.IsPaymentOverdue;
            userDtm.IsMale           = user.IsMale;
            userDtm.Birthdate        = user.Birthdate;

            if (user.Country != null)
            {
                CountryDTM country = new CountryDTM();
                country.Id          = user.Country.Id;
                country.Code        = user.Country.Code;
                country.Name        = user.Country.Name;
                country.Native      = user.Country.Native;
                country.PhonePrefix = user.Country.PhonePrefix;
                country.Capital     = user.Country.Capital;
                country.Currency_   = user.Country.Currency_;
                country.Emoji       = user.Country.Emoji;
                country.EmojiU      = user.Country.EmojiU;
                userDtm.Country     = country;
            }

            if (user.Time_zone != null)
            {
                Time_zoneDTM tz = new Time_zoneDTM();
                tz.Id             = user.Time_zone.Id;
                tz.Zone           = user.Time_zone.Zone;
                tz.CountryCode    = user.Time_zone.CountryCode;
                tz.UTC_Jan_1_2020 = user.Time_zone.UTC_Jan_1_2020;
                tz.DST_Jul_1_2020 = user.Time_zone.DST_Jul_1_2020;
                userDtm.Time_zone = tz;
            }
            return(userDtm);
        }
Example #5
0
        public static CountryDTM changeToDTM(Country country)
        {
            CountryDTM countryDtm = new CountryDTM
            {
                Id          = country.Id,
                Code        = country.Code,
                Name        = country.Name,
                Native      = country.Native,
                PhonePrefix = country.PhonePrefix,
                Capital     = country.Capital,
                Currency_   = country.Currency_,
                Emoji       = country.Emoji,
                EmojiU      = country.EmojiU
            };

            return(countryDtm);
        }
Example #6
0
        public static Country changeFromDTM(CountryDTM countryDtm)
        {
            Country country = new Country
            {
                Id          = countryDtm.Id,
                Code        = countryDtm.Code,
                Name        = countryDtm.Name,
                Native      = countryDtm.Native,
                PhonePrefix = countryDtm.PhonePrefix,
                Capital     = countryDtm.Capital,
                Currency_   = countryDtm.Currency_,
                Emoji       = countryDtm.Emoji,
                EmojiU      = countryDtm.EmojiU
            };

            return(country);
        }
        public async Task <List <BusinessDTM> > GetAll(SearchParams search)
        {
            //var config = new MapperConfiguration(cfg => {
            //    cfg.CreateMap<Business, BusinessDTM>();
            //    cfg.CreateMap<Country, CountryDTM>();
            //    cfg.CreateMap<Currency, CurrencyDTM>();
            //    cfg.CreateMap<Time_zone, Time_zoneDTM>();
            //    cfg.CreateMap<Booking, BookingDTM>();
            //});
            //var mapper = new Mapper(config);
            //return await Task.Run(() => (mapper.Map<List<BusinessDTM>>(
            //    Database.Businesses.GetAll()
            //   .OrderBy(u => u.Name)
            //   .Skip(search.PageSize * search.Page)
            //   .Take(search.PageSize))));
            //return mapper.Map<List<BusinessDTM>>(
            //       Database.Businesses.GetAll()
            //      .OrderBy(u => u.Name)
            //      .Skip(search.PageSize * search.Page)
            //      .Take(search.PageSize));
            List <BusinessDTM> bListDtm = new List <BusinessDTM>();
            List <Business>    bList    = Database.Businesses.GetAll()
                                          .OrderBy(u => u.Name)
                                          .Skip(search.PageSize * search.Page)
                                          .Take(search.PageSize).ToList();

            foreach (Business b in bList)
            {
                BusinessDTM bDtm = new BusinessDTM();
                bDtm.Id                 = b.Id;
                bDtm.Name               = b.Name;
                bDtm.Phone              = b.Phone;
                bDtm.Logo               = b.Logo;
                bDtm.Webpage            = b.Webpage;
                bDtm.Address            = b.Address;
                bDtm.City               = b.City;
                bDtm.State              = b.State;
                bDtm.ZipCode            = b.ZipCode;
                bDtm.RegistrationNumber = b.RegistrationNumber;

                bDtm.CountryId   = b.Country.Id;
                bDtm.CurrencyId  = b.Currency.Id;
                bDtm.Time_zoneId = b.Time_zone.Id;

                CountryDTM country = new CountryDTM();
                country.Id          = b.Country.Id;
                country.Code        = b.Country.Code;
                country.Name        = b.Country.Name;
                country.Native      = b.Country.Native;
                country.PhonePrefix = b.Country.PhonePrefix;
                country.Capital     = b.Country.Capital;
                country.Currency_   = b.Country.Currency_;
                country.Emoji       = b.Country.Emoji;
                country.EmojiU      = b.Country.EmojiU;
                bDtm.Country        = country;

                CurrencyDTM currency = new CurrencyDTM();
                currency.Id   = b.Currency.Id;
                currency.Name = b.Currency.Name;
                bDtm.Currency = currency;

                Time_zoneDTM tz = new Time_zoneDTM();
                tz.Id             = b.Time_zone.Id;
                tz.Zone           = b.Time_zone.Zone;
                tz.CountryCode    = b.Time_zone.CountryCode;
                tz.UTC_Jan_1_2020 = b.Time_zone.UTC_Jan_1_2020;
                tz.DST_Jul_1_2020 = b.Time_zone.DST_Jul_1_2020;
                bDtm.Time_zone    = tz;

                bListDtm.Add(bDtm);
            }

            return(bListDtm);
        }
        public async Task <BusinessDTM> Get(int id)
        {
            int firstBusinessId = 1;

            if (id < firstBusinessId)
            {
                throw new ValidationException("Business id is not specified correctly", "");
            }
            var business = await Database.Businesses.Get(id);

            if (business == null)
            {
                throw new ValidationException("Business is not found", "");
            }

            BusinessDTM bDtm = new BusinessDTM();

            bDtm.Id                 = business.Id;
            bDtm.Name               = business.Name;
            bDtm.Phone              = business.Phone;
            bDtm.Logo               = business.Logo;
            bDtm.Webpage            = business.Webpage;
            bDtm.Address            = business.Address;
            bDtm.City               = business.City;
            bDtm.State              = business.State;
            bDtm.ZipCode            = business.ZipCode;
            bDtm.RegistrationNumber = business.RegistrationNumber;

            if (business.Country != null)
            {
                CountryDTM country = new CountryDTM();
                country.Id          = business.Country.Id;
                country.Code        = business.Country.Code;
                country.Name        = business.Country.Name;
                country.Native      = business.Country.Native;
                country.PhonePrefix = business.Country.PhonePrefix;
                country.Capital     = business.Country.Capital;
                country.Currency_   = business.Country.Currency_;
                country.Emoji       = business.Country.Emoji;
                country.EmojiU      = business.Country.EmojiU;
                bDtm.Country        = country;
                bDtm.CountryId      = business.Country.Id;
            }
            if (business.Currency != null)
            {
                CurrencyDTM currency = new CurrencyDTM();
                currency.Id     = business.Currency.Id;
                currency.Name   = business.Currency.Name;
                bDtm.Currency   = currency;
                bDtm.CurrencyId = business.Currency.Id;
            }
            if (business.Time_zone != null)
            {
                Time_zoneDTM tz = new Time_zoneDTM();
                tz.Id             = business.Time_zone.Id;
                tz.Zone           = business.Time_zone.Zone;
                tz.CountryCode    = business.Time_zone.CountryCode;
                tz.UTC_Jan_1_2020 = business.Time_zone.UTC_Jan_1_2020;
                tz.DST_Jul_1_2020 = business.Time_zone.DST_Jul_1_2020;
                bDtm.Time_zone    = tz;
                bDtm.Time_zoneId  = business.Time_zone.Id;
            }
            //var config = new MapperConfiguration(cfg => cfg.CreateMap<Business, BusinessDTM>());
            //var mapper = new Mapper(config);
            //return mapper.Map<BusinessDTM>(business);
            return(bDtm);
        }