コード例 #1
0
ファイル: CalendarItemTest.cs プロジェクト: Confirmit/Portal
        public void CalendarItem_GetCalendarItem_NotInCache_InDatabase()
        {
            CalendarDetails details = new CalendarDetails();
            details.ID = 1;
            details.Date = new DateTime(2008, 10, 6);
            details.WorkTime = new DateTime(2008, 10, 6, 8, 30, 0);

            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {
                recorder.ExpectAndReturn(CalendarItem.Cache.ContainsKey(null), false);
                SiteProvider.Calendar.GetCalendarDetails(DateTime.Now);
                recorder.Return(details);

                CalendarItem.Cache[null] = null;
            }

            CalendarItem item = CalendarItem.GetCalendarItem(new DateTime(2008, 10, 6));
            Assert.IsNotNull(item);
            Assert.AreEqual(new TimeSpan(8, 30, 0), item.WorkTime);
            Assert.AreEqual(new DateTime(2008, 10, 6), item.Date);
            Assert.IsTrue(item.IsSaved);
        }
コード例 #2
0
ファイル: CalendarProvider.cs プロジェクト: Confirmit/Portal
 /// <summary>
 /// Updates details in database.
 /// </summary>
 /// <param name="details">Calendar details.</param>
 public abstract bool UpdateDetails( CalendarDetails details );
コード例 #3
0
ファイル: CalendarProvider.cs プロジェクト: Confirmit/Portal
 /// <summary>
 /// Inserts details in database.
 /// </summary>
 /// <param name="details">Calendar details.</param>
 /// <returns>ID of inserted record.</returns>
 public abstract int InsertDetails( CalendarDetails details );
コード例 #4
0
ファイル: CalendarItem.cs プロジェクト: Confirmit/Portal
        /// <summary>
        /// Inserts item to database.
        /// </summary>
        /// <param name="id">ID of record to update.</param>
        /// <param name="date">Date.</param>
        /// <param name="workTime">Work time.</param>
        /// <param name="comment">Comment</param>
        /// <returns>If record was updated.</returns>
        public static bool UpdateCalendarItem(int id, DateTime date, TimeSpan workTime, string comment)
        {
            Cache.Remove(GetCacheDateKey(date.Date));

            CalendarDetails details = new CalendarDetails();
            details.ID = id;
            details.Date = date.Date;
            details.WorkTime = date.Date + workTime;
            details.Comment = comment;
            return SiteProvider.Calendar.UpdateDetails(details);
        }
コード例 #5
0
ファイル: CalendarItem.cs プロジェクト: Confirmit/Portal
        /// <summary>
        /// Inserts item to database.
        /// </summary>
        /// <param name="date">Date.</param>
        /// <param name="workTime">Work time.</param>
        /// <param name="comment">Comment</param>
        /// <returns>ID of inserted record.</returns>
        public static int InsertCalendarItem(DateTime date, TimeSpan workTime, string comment)
        {
            Cache.Remove(GetCacheDateKey(date.Date));

            CalendarDetails details = new CalendarDetails();
            details.Date = date.Date;
            details.WorkTime = date.Date + workTime;
            details.Comment = comment;
            return SiteProvider.Calendar.InsertDetails(details);
        }