public List <FrayteCountryCode> lstCountry()
        {
            var lstCountry = dbContext.Countries.ToList();

            List <FrayteCountryCode> lstFrayteCountry = new List <FrayteCountryCode>();

            foreach (Country country in lstCountry)
            {
                FrayteCountryCode frayteCountry = new FrayteCountryCode();
                frayteCountry.CountryId      = country.CountryId;
                frayteCountry.Name           = country.CountryName;
                frayteCountry.Code           = country.CountryCode;
                frayteCountry.Code2          = country.CountryCode2;
                frayteCountry.TimeZoneDetail = new TimeZoneModal();
                if (country.TimeZoneId != null && country.TimeZoneId > 0)
                {
                    var timeZone = dbContext.Timezones.Find(country.TimeZoneId.Value);
                    if (timeZone != null)
                    {
                        frayteCountry.TimeZoneDetail.TimezoneId  = timeZone.TimezoneId;
                        frayteCountry.TimeZoneDetail.Name        = timeZone.Name;
                        frayteCountry.TimeZoneDetail.OffsetShort = timeZone.OffsetShort;
                        frayteCountry.TimeZoneDetail.Offset      = timeZone.Offset;
                    }
                }

                lstFrayteCountry.Add(frayteCountry);
            }

            return(lstFrayteCountry);
        }
        public FrayteCountryCode GetCountryByTimezone(int timezoneId)
        {
            var country = dbContext.Countries.Where(p => p.TimeZoneId == timezoneId).FirstOrDefault();
            FrayteCountryCode frayteCountry = new FrayteCountryCode();

            if (country != null)
            {
                frayteCountry.CountryId      = country.CountryId;
                frayteCountry.Name           = country.CountryName;
                frayteCountry.Code           = country.CountryCode;
                frayteCountry.TimeZoneDetail = new TimeZoneModal();
                if (country.TimeZoneId != null && country.TimeZoneId > 0)
                {
                    var timeZone = dbContext.Timezones.Find(country.TimeZoneId.Value);
                    if (timeZone != null)
                    {
                        frayteCountry.TimeZoneDetail.TimezoneId  = timeZone.TimezoneId;
                        frayteCountry.TimeZoneDetail.Name        = timeZone.Name;
                        frayteCountry.TimeZoneDetail.OffsetShort = timeZone.OffsetShort;
                        frayteCountry.TimeZoneDetail.Offset      = timeZone.Offset;
                    }
                }
                return(frayteCountry);
            }


            return(null);
        }
Beispiel #3
0
        public FrayteCountryCode GetWareHouseCountry(int?countryId)
        {
            FrayteCountryCode WareHouseCountry;

            if (countryId.HasValue && countryId > 0)
            {
                WareHouseCountry = new FrayteCountryCode();
                var country = dbContext.Countries.Find(countryId.Value);
                WareHouseCountry.Code      = country.CountryCode;
                WareHouseCountry.Code2     = country.CountryCode2;
                WareHouseCountry.CountryId = country.CountryId;
                WareHouseCountry.Name      = country.CountryName;
                return(WareHouseCountry);
            }
            else
            {
                return(null);
            }
        }