コード例 #1
0
ファイル: CountryObject.cs プロジェクト: Organus/LRS_SORT
 public CountryObject SaveCountry(CountryObject country)
 {
     if (country.CountryId > 0) // Update
     {
         string sql = @"
             UPDATE  lu_Country
             SET     Country = @Country,
                     CountryCode = @CountryCode,
                     Active = @Active
             WHERE   CountryId = @CountryId";
         Config.Conn.Execute(sql, country);
     }
     else
     {
         string sql = @"
             INSERT INTO lu_Country (
                 Country,
                 CountryCode,
                 Active
             )
             VALUES (
                 @Country,
                 @CountryCode,
                 @Active
             )
             SELECT CAST(SCOPE_IDENTITY() AS INT)";
         country.CountryId = Config.Conn.Query <int>(sql, country).Single();
     }
     return(country);
 }
コード例 #2
0
ファイル: CountryObject.cs プロジェクト: Organus/LRS_SORT
 public bool DeleteCountry(CountryObject country)
 {
     try
     {
         Config.Conn.Execute("DELETE FROM lu_Country WHERE CountryId = @CountryId", country);
     }
     catch { return(false); }
     return(true);
 }
コード例 #3
0
ファイル: MemoryCache.cs プロジェクト: Organus/LRS_SORT
        public static List <CountryObject> GetCountries(bool enabledOnly = false, int?requiredId = null)
        {
            var cache = HttpContext.Current.Cache;
            List <CountryObject> data = (List <CountryObject>)cache[CountryKey];

            if (data == null)
            {
                data = CountryObject.GetCountries();
                cache.Insert(CountryKey, data, null, DateTime.Now.AddMinutes(60), Cache.NoSlidingExpiration);
            }
            return(data.Where(n => (!enabledOnly || n.Active || (requiredId.HasValue && n.CountryId == requiredId.Value))).ToList());
        }