public authorityItem GetAuthById(string id) { try { logger.LogMethod("jo", "GetAuthById", "Enter"); //List<authorityItem> list = new List<authorityItem>(); authorityItem temp = new authorityItem(); key = id + "GetAuthById"; if (CachingConfig.CachingEnabled) { temp = (authorityItem)WCFCache.Current[key]; if (temp != null) { logger.LogMethod("jo", "GetAuthById", "Cache found"); return temp; } } temp = new authorityItem(); context = new SocialCopsEntities(); int aid = Convert.ToInt32(id); List<Authority> auths = (from a in context.Authorities where a.authId == aid orderby a.date descending select a).ToList(); if (auths.Count == 0) { error.ErrorMessage = "The auth doesn't exist."; error.ErrorDetails = "The auth doesn't exist."; error.Result = false; logger.LogMethod("jo", "GetAuthById", "The auth doesn't exist."); throw new FaultException<Bug>(error); } foreach (Authority auth in auths) { //authorityItem temp = new authorityItem(); temp.authId = auth.authId; temp.authName = auth.authName; temp.authAddress = auth.authAddress; temp.email = auth.email; temp.phone = Convert.ToInt32(auth.phone); temp.numPending = (int)auth.numPending; temp.numResolved = (int)auth.numResolved; temp.latitude = temp.latitude; temp.longitude = temp.longitude; temp.website = auth.website; temp.profilePic = auth.profilePic; temp.flag = (int)auth.flag; temp.date = auth.date; temp.city = auth.city; temp.state = auth.state; temp.country = auth.country; temp.pincode = auth.pincode; //list.Add(temp); } Cache.Cache.AddToCache(key, temp); logger.LogMethod("jo", "GetAuthById", "Exit"); return temp; } catch (Exception ex) { error.ErrorDetails = ex.Message.ToString(); error.ErrorMessage = "Something happened. Sorry."; error.Result = false; logger.LogMethod("jo", "GetAuthById", ex.Message.ToString()); throw new FaultException<Bug>(error, ex.Message.ToString()); } }
public authorityItem GetCopy() { authorityItem copy = (authorityItem)this.MemberwiseClone(); return(copy); }
public authorityItem[] GetAuthsByState(string state) { try { logger.LogMethod("jo", "GetAuthsByState", "Enter"); List<authorityItem> list = new List<authorityItem>(); key = state + "GetAuthsByState"; if (CachingConfig.CachingEnabled) { list = (List<authorityItem>)WCFCache.Current[key]; if (list != null) { logger.LogMethod("jo", "GetAuthsByState", "Cache found"); return list.ToArray(); } } list = new List<authorityItem>(); context = new SocialCopsEntities(); List<Authority> auths = (from a in context.Authorities where a.state == state orderby a.date descending select a).ToList(); foreach (Authority auth in auths) { authorityItem temp = new authorityItem(); temp.authId = auth.authId; temp.authName = auth.authName; temp.authAddress = auth.authAddress; temp.email = auth.email; temp.phone = Convert.ToInt32(auth.phone); temp.numPending = (int)auth.numPending; temp.numResolved = (int)auth.numResolved; temp.latitude = temp.latitude; temp.longitude = temp.longitude; temp.website = auth.website; temp.profilePic = auth.profilePic; temp.flag = (int)auth.flag; temp.date = auth.date; temp.city = auth.city; temp.state = auth.state; temp.country = auth.country; temp.pincode = auth.pincode; list.Add(temp); } Cache.Cache.AddToCache(key, list); logger.LogMethod("jo", "GetAuthsByState", "Exit"); return list.ToArray(); } catch (Exception ex) { error.ErrorDetails = ex.Message.ToString(); error.ErrorMessage = "Something happened. Sorry."; error.Result = false; logger.LogMethod("jo", "GetAuthsByState", ex.Message.ToString()); throw new FaultException<Bug>(error, ex.Message.ToString()); } }