Exemplo n.º 1
0
 public CoreCapabilitiesObject SaveCoreCapabilities(CoreCapabilitiesObject coreCapabilities)
 {
     if (coreCapabilities.CoreCapabilitiesId > 0) // Update
     {
         string sql = @"
             UPDATE  lu_CoreCapabilities
             SET     Name = @Name,
                     Active = @Active
             WHERE   CoreCapabilitiesId = @CoreCapabilitiesId";
         Config.Conn.Execute(sql, coreCapabilities);
     }
     else
     {
         string sql = @"
             INSERT INTO lu_CoreCapabilities (
                 Name,
                 Active
             )
             VALUES (
                 @Name,
                 @Active
             )
             SELECT CAST(SCOPE_IDENTITY() AS INT)";
         coreCapabilities.CoreCapabilitiesId = Config.Conn.Query <int>(sql, coreCapabilities).Single();
     }
     return(coreCapabilities);
 }
Exemplo n.º 2
0
        public static List <CoreCapabilitiesObject> GetCoreCapabilities(bool enabledOnly = false, int?requiredId = null)
        {
            var cache = HttpContext.Current.Cache;
            List <CoreCapabilitiesObject> data = (List <CoreCapabilitiesObject>)cache[CoreCapabilitiesKey];

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