public BugComment UpdateBugComment(BugComment bugComment)
        {
            var bug = context.BugComments.Attach(bugComment);

            bug.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(bugComment);
        }
        public BugComment DeleteBugComment(int id)
        {
            BugComment bugComment = context.BugComments.Find(id);

            if (bugComment != null)
            {
                context.BugComments.Remove(bugComment);
                context.SaveChanges();
            }
            return(bugComment);
        }
Exemplo n.º 3
0
        public Dictionary <int, BugComment[]> GetComments(int[] bugIds, bool withAttachments)
        {
            BugGetComments args = new BugGetComments();

            args.ids = bugIds;
            GetCommentsResult res = Proxy.GetComments(args);
            Dictionary <int, BugComment[]> dict = new Dictionary <int, BugComment[]> ();
            List <int> attIds = new List <int>();
            Dictionary <int, BugComment> attTargets = new Dictionary <int, BugComment> ();

            foreach (DictionaryEntry e in res.bugs)
            {
                string            bugId    = (string)e.Key;
                XmlRpcStruct      cms      = (XmlRpcStruct)e.Value;
                object[]          cmsArray = (object[])cms ["comments"];
                List <BugComment> list     = new List <BugComment> ();
                foreach (XmlRpcStruct cm in cmsArray)
                {
                    BugComment c = new BugComment();
                    if (cm.Contains("attachment_id"))
                    {
                        c.attachment_id = (int)cm ["attachment_id"];
                    }
                    c.author     = (string)cm ["author"];
                    c.is_private = (bool)cm ["is_private"];
                    c.text       = (string)cm ["text"];
                    c.time       = (DateTime)cm ["time"];
                    list.Add(c);
                    if (c.attachment_id != 0)
                    {
                        attIds.Add(c.attachment_id);
                        attTargets [c.attachment_id] = c;
                    }
                }
                dict [int.Parse(bugId)] = list.ToArray();
            }

            if (withAttachments && attIds.Count > 0)
            {
                Dictionary <int, BugAttachment> atts = GetAttachments(attIds.ToArray());
                foreach (BugAttachment at in atts.Values)
                {
                    BugComment c = attTargets [at.id];
                    c.attachment = at;
                }
            }

            return(dict);
        }
        public RedirectToActionResult Details(BugCommentsViewModel bugCommentsViewModel)
        {
            var        userid     = userManager.GetUserId(User);
            BugComment bugComment = new BugComment
            {
                BugId             = bugCommentsViewModel.bug.BugId,
                Comment           = bugCommentsViewModel.bugComment.Comment,
                CommentDate       = DateTime.Now,
                ApplicationUserId = userid,
            };

            _bugCommentRepository.AddBugComment(bugComment);

            return(RedirectToAction());
        }
Exemplo n.º 5
0
        public Dictionary<int, BugComment[]> GetComments(int[] bugIds, bool withAttachments)
        {
            BugGetComments args = new BugGetComments ();
            args.ids = bugIds;
            GetCommentsResult res = Proxy.GetComments (args);
            Dictionary<int, BugComment[]> dict = new Dictionary<int, BugComment[]> ();
            List<int> attIds = new List<int>();
            Dictionary<int, BugComment> attTargets = new Dictionary<int, BugComment> ();

            foreach (DictionaryEntry e in res.bugs) {
                string bugId = (string) e.Key;
                XmlRpcStruct cms = (XmlRpcStruct) e.Value;
                object[] cmsArray = (object[]) cms ["comments"];
                List<BugComment> list = new List<BugComment> ();
                foreach (XmlRpcStruct cm in cmsArray) {
                    BugComment c = new BugComment ();
                    if (cm.Contains ("attachment_id"))
                        c.attachment_id = (int) cm ["attachment_id"];
                    c.author = (string) cm ["author"];
                    c.is_private = (bool) cm ["is_private"];
                    c.text = (string) cm ["text"];
                    c.time = (DateTime) cm ["time"];
                    list.Add (c);
                    if (c.attachment_id != 0) {
                        attIds.Add (c.attachment_id);
                        attTargets [c.attachment_id] = c;
                    }
                }
                dict [int.Parse (bugId)] = list.ToArray ();
            }

            if (withAttachments && attIds.Count > 0) {
                Dictionary<int,BugAttachment> atts = GetAttachments (attIds.ToArray ());
                foreach (BugAttachment at in atts.Values) {
                    BugComment c = attTargets [at.id];
                    c.attachment = at;
                }
            }

            return dict;
        }
 public BugComment AddBugComment(BugComment bugComment)
 {
     context.BugComments.Add(bugComment);
     context.SaveChanges();
     return(bugComment);
 }