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); }
/// <summary> /// Updates details in database. /// </summary> /// <param name="details">Calendar details.</param> public abstract bool UpdateDetails( CalendarDetails details );
/// <summary> /// Inserts details in database. /// </summary> /// <param name="details">Calendar details.</param> /// <returns>ID of inserted record.</returns> public abstract int InsertDetails( CalendarDetails details );
/// <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); }
/// <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); }