Exemplo n.º 1
0
        public commentItem GetCopy()
        {
            commentItem copy = (commentItem)this.MemberwiseClone();

            return(copy);
        }
Exemplo n.º 2
0
        public bool SaveComment(commentItem comment)
        {
            try
            {
                logger.LogMethod("DEBUG", "SaveComment/{complaintId}", comment.complaintId + "/ started SaveComment/{complaintId}", null);
                context = new SocialCopsEntities();
                Comment temp = new Comment();
                temp.comment1 = comment.comment;
                temp.complaintId = comment.complaintId;
                temp.userId = comment.userId;
                temp.date = System.DateTime.Now;
                context.Comments.Add(temp);
                context.SaveChanges();
                logger.LogMethod("DEBUG", "SaveComment/{complaintId}", comment.complaintId + "/ finished SaveComment/{complaintId}", null);
                return true;

            }
            catch (Exception ex)
            {
                error.ErrorMessage = "Something happened. Sorry.";
                error.Result = false;
                logger.LogMethod("ERROR", "SaveComment/{complaintId}", comment.complaintId +ex.ToString(), null);
                throw new FaultException<Bug>(error, ex.Message.ToString());
            }
        }
Exemplo n.º 3
0
        public commentItem[] GetComments(String complaintId)
        {
            try
            {
                logger.LogMethod("DEBUG", "GetComments/{complaintId}", complaintId + "/ started GetComments/{complaintId}", null);
                List<commentItem> list = new List<commentItem>();
                key = complaintId + "GetComments";
                if (CachingConfig.CachingEnabled)
                {
                    list = (List<commentItem>)WCFCache.Current[key];
                    if (list != null)
                    {
                        logger.LogMethod("CACHE", "GetComments/{complaintId}", complaintId + "/ Cache Found - finished GetComments/{complaintId}", null);
                        return list.ToArray();
                    }
                }
                list = new List<commentItem>();
                context = new SocialCopsEntities();
                int cid = Convert.ToInt32(complaintId);
                List<Comment> comments = (from c
                                          in context.Comments
                                          where c.complaintId == cid
                                          orderby c.date descending
                                          select c).ToList();

                foreach (Comment comment in comments)
                {
                    commentItem temp = new commentItem();
                    temp.comment = comment.comment1;
                    temp.complaintId = comment.complaintId;
                    temp.userId = comment.userId;
                    temp.date = comment.date;
                    list.Add(temp);
                }
                Cache.Cache.AddToCache(key, list);
                logger.LogMethod("DEBUG", "GetComments/{complaintId}", complaintId + "/ finished GetComments/{complaintId}", null);
                return list.ToArray();
            }
            catch (Exception ex)
            {
                error.Result = false;
                error.ErrorMessage = "Something happened. Sorry";
                logger.LogMethod("ERROR", "GetComments/{complaintId}", complaintId + ex.ToString(), null);
                throw new FaultException<Bug>(error, ex.Message.ToString());
            }
        }
Exemplo n.º 4
0
 public bool SaveComment(commentItem comment)
 {
     cc = new ComplaintController();
     bool result = cc.SaveComment(comment);
     return result;
 }