public spamItem GetCopy() { spamItem copy = (spamItem)this.MemberwiseClone(); return(copy); }
public spamItem[] GetSpam(string complaintId) { try { logger.LogMethod("DEBUG", "GetSpam/{complaintId}", complaintId + "/ started GetSpam/{complaintId}", null); List<spamItem> list = new List<spamItem>(); key = complaintId + "GetSpam"; if (CachingConfig.CachingEnabled) { list = (List<spamItem>)WCFCache.Current[key]; if (list != null) { logger.LogMethod("CACHE", "GetSpam/{complaintId}", complaintId + "/ Cache Found - GetSpam/{complaintId}", null); return list.ToArray(); } } list = new List<spamItem>(); context = new SocialCopsEntities(); //Retrieving records from the database int cid = Convert.ToInt32(complaintId); List<Spam> spams = (from s in context.Spams where s.complaintId == cid orderby s.date descending select s).ToList(); foreach (Spam spam in spams) { spamItem temp = new spamItem(); temp.complaintId = spam.complaintId; temp.userId = spam.userId; temp.date = spam.date; list.Add(temp); } Cache.Cache.AddToCache(key, list); logger.LogMethod("DEBUG", "GetSpam/{complaintId}", complaintId + "/ finished GetSpam/{complaintId}", null); return list.ToArray(); } catch (Exception ex) { error.ErrorMessage = "Something happened. Sorry."; error.ErrorDetails = ex.ToString(); error.Result = false; logger.LogMethod("ERROR", "GetSpam/{complaintId}", complaintId + ex.ToString(), null); throw new FaultException<Bug>(error, ex.Message.ToString()); } }
public bool SaveSpam(spamItem spam) { try { logger.LogMethod("DEBUG", "SaveSpam/{complaintId}", spam.complaintId + "/ started SaveSpam/{complaintId}", null); context = new SocialCopsEntities(); Spam temp = new Spam(); temp.date = spam.date; temp.complaintId = spam.complaintId; temp.userId = spam.userId; context.Spams.Add(temp); context.SaveChanges(); logger.LogMethod("DEBUG", "SaveSpam/{complaintId}", spam.complaintId + "/ finished SaveSpam/{complaintId}", null); return true; } catch (Exception ex) { error.Result = false; error.ErrorMessage = "Something happened. Sorry."; error.ErrorDetails = ex.ToString(); logger.LogMethod("ERROR", "SaveSpam/{complaintId}", spam.complaintId + ex.ToString(), null); throw new FaultException<Bug>(error, ex.Message.ToString()); } }
public bool SaveSpam(spamItem spam) { cc = new ComplaintController(); bool result = cc.SaveSpam(spam); return result; }