/// <summary> /// Retreives the apporpirate SpotsStatus object from the DB based on the enum value passed in /// </summary> /// <param name="oSpotStatus"></param> /// <returns></returns> private IASpotStatus GetSpotStatusFromDB(SpotStatus oSpotStatus) { IASpotStatus oIASpotStatus = null; switch (oSpotStatus) { case SpotStatus.OnHold: oIASpotStatus = DataAccess.IASpotStatus.SingleOrDefault(row => row.Name == "On Hold"); break; case SpotStatus.Unviewed: oIASpotStatus = DataAccess.IASpotStatus.SingleOrDefault(row => row.Name == "Unviewed"); break; case SpotStatus.Viewed: oIASpotStatus = DataAccess.IASpotStatus.SingleOrDefault(row => row.Name == "Viewed"); break; case SpotStatus.Finished: oIASpotStatus = DataAccess.IASpotStatus.SingleOrDefault(row => row.Name == "Finished"); break; case SpotStatus.NeedsFix: oIASpotStatus = DataAccess.IASpotStatus.SingleOrDefault(row => row.Name == "Needs Fix"); break; default: throw new ApplicationException(string.Format("Spot status is undefined or doesn't exist: {0}", oSpotStatus.ToString())); } return oIASpotStatus; }
public int GetSpotStatusID(SpotStatus oSpotStatus) { var iSpotStatusID = 0; var sCacheItemKey = "SpotStatus-" + oSpotStatus.ToString(); if (HttpContext.Current.Cache[sCacheItemKey] == null) { iSpotStatusID = GetSpotStatusFromDB(oSpotStatus).IASpotStatusID; HttpContext.Current.Cache.Add(sCacheItemKey, iSpotStatusID, null, DateTime.Now.AddSeconds(3600), TimeSpan.Zero, CacheItemPriority.Normal, null); } else { iSpotStatusID = (int) HttpContext.Current.Cache[sCacheItemKey]; } return iSpotStatusID; }
public static StatusOption GetStatusOption(SpotStatus status, DataAccessDataContext context) { return StatusService.GetStatuses(context)[StatusType.SpotStatus].Where(s => s.SystemName == status.ToString()).SingleOrDefault(); }