/// <summary> /// Refresh database context, open time and close time of resources. /// </summary> public static void RefreshContext() { EssResources = Resource.LoadList(); EssResourceDetail = ResourceDetail.LoadList(); OpenTime = Convert.ToDateTime((from c in EssResources select c.BookingOpenFrom).Min()).TimeOfDay; CloseTime = Convert.ToDateTime((from c in EssResources select c.BookingOpenTo).Max()).TimeOfDay; }
/// <summary> /// Retrieve booking open time to close time from table for respective resources. /// </summary> /// <param name="resName">Name of resource for which time need to be retrieved.</param> /// <param name="openTime">TimeSpan parameter in which open time will be set.</param> /// <param name="closeTime">TimeSpan parameter in which close time will be set.</param> public static void GetHours(string resName, out TimeSpan?openTime, out TimeSpan?closeTime) { EssResources = Resource.LoadList(); var bookingHours = from c in EssResources where c.ResourceName.Equals(resName) select new { OpenTime = c.BookingOpenFrom, CloseTime = c.BookingOpenTo }; var hourData = bookingHours.FirstOrDefault(); if (hourData != null) { openTime = (Convert.ToDateTime(hourData.OpenTime)).TimeOfDay; closeTime = (Convert.ToDateTime(hourData.CloseTime)).TimeOfDay; } else { openTime = closeTime = null; } }