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

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