예제 #1
0
 public SppCategoryObject SaveSppCategory(SppCategoryObject sppCategory)
 {
     if (sppCategory.SppCategoryId > 0) // Update
     {
         string sql = @"
             UPDATE  lu_SppCategory
             SET     CategoryCode = @CategoryCode,
                     Category = @Category,
                     Active = @Active
             WHERE   SppCategoryId = @SppCategoryId";
         Config.Conn.Execute(sql, sppCategory);
     }
     else
     {
         string sql = @"
             INSERT INTO lu_SppCategory (
                 CategoryCode,
                 Category,
                 Active
             )
             VALUES (
                 @CategoryCode,
                 @Category,
                 @Active
             )
             SELECT CAST(SCOPE_IDENTITY() AS INT)";
         sppCategory.SppCategoryId = Config.Conn.Query <int>(sql, sppCategory).Single();
     }
     return(sppCategory);
 }
예제 #2
0
 public bool DeleteSppCategory(SppCategoryObject sppCategory)
 {
     try
     {
         Config.Conn.Execute("DELETE FROM lu_SppCategory WHERE SppCategoryId = @SppCategoryId", sppCategory);
     }
     catch { return(false); }
     return(true);
 }
예제 #3
0
        public static List <SppCategoryObject> GetSppFunding(bool enabledOnly = false, int?requiredId = null)
        {
            var cache = HttpContext.Current.Cache;
            List <SppCategoryObject> data = (List <SppCategoryObject>)cache[SppFundingKey];

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