Exemplo n.º 1
0
        public static IssueViewModel AssignAreasReleasesAndTypesToIssue(IssueViewModel issue)
        {
            issue.Areas = ConfigService.Areas
                            .Select(a => new OptionViewModel() { Selected = a.Equals(issue.Area, StringComparison.OrdinalIgnoreCase), Text = a, Value = a })
                            .ToList();

            issue.Releases = ConfigService.Releases
                               .Select(r => new OptionViewModel() { Selected = r.Equals(issue.Release, StringComparison.OrdinalIgnoreCase), Text = r, Value = r })
                               .ToList();

            issue.Types = ConfigService.Types
                               .Select(t => new OptionViewModel() { Selected = (t == issue.Type), Text = t.ToString(), Value = t.ToString() })
                               .ToList();
            return issue;
        }
Exemplo n.º 2
0
        public static void SendIssueComment(IssueViewModel issue, long commentId)
        {
            IssueCommentViewModel comment = issue.Comments.Where(c => c.Id == commentId).SingleOrDefault();
            var vm = new { app = new AppViewModel(), issue = issue, comment = comment };
            string subject = Render.StringToString(CommentSubject, vm);
            string body = Render.StringToString(CommentBody, vm);

            // Initialize sending emails to all comments.
            HashSet<string> emails = new HashSet<string>(issue.Comments.Select(c => c.CommentByUserEmail));
            emails.Add(issue.CreatedByUserEmail); // Send to the opener of the issue.
            emails.Add(issue.AssignedToUserEmail); // Send to the holder of the issue.

            // Don't send emails to users that don't have emails nor the user that left the comment.
            emails.RemoveWhere(s => String.IsNullOrEmpty(s) || s.Equals(comment.CommentByUserEmail, StringComparison.OrdinalIgnoreCase));

            foreach (string email in emails)
            {
                Send(email, subject, body);
            }
        }
Exemplo n.º 3
0
        public static void SendIssueComment(IssueViewModel issue, long commentId)
        {
            IssueCommentViewModel comment = issue.Comments.Where(c => c.Id == commentId).SingleOrDefault();
            var vm = new { app = new AppViewModel(), issue = issue, comment = comment };
            string subject = Render.StringToString(CommentSubject, vm);
            string body = Render.StringToString(CommentBody, vm);

            // Send to the opener of the issue if not the commenter.
            if (comment.CommentByUserId != issue.CreatedByUserId &&
                !String.IsNullOrEmpty(issue.CreatedByUserEmail))
            {
                Send(issue.CreatedByUserEmail, subject, body);
            }

            // Send to the holder of the issue if not also the commenter and opener.
            if (comment.CommentByUserId != issue.AssignedToUserId &&
                issue.AssignedToUserId != issue.CreatedByUserId &&
                !String.IsNullOrEmpty(issue.AssignedToUserEmail))
            {
                Send(issue.AssignedToUserEmail, subject, body);
            }
        }
Exemplo n.º 4
0
        public static void WriteIssue(IssueViewModel issue, BreadcrumbsViewModel breadcrumbs, AppViewModel app = null)
        {
            string file = Path.Combine(ConfigService.RootPath, issue.Id.ToString() + "\\index.html");

            Template template = LoadTemplate("bug.mustache");
            RenderTemplateToFile(template, new { app = app ?? new AppViewModel(), breadcrumbs = breadcrumbs, issue = issue }, file);
        }
Exemplo n.º 5
0
        public static bool TryGetIssueWithCommentsUsingDb(long issueId, IDbConnection db, out IssueViewModel issue)
        {
            SqlBuilder sql = new SqlBuilder();
            sql.Where("Issue.Id=@id", new { id = issueId });
            var issueTemplate = sql.AddTemplate(IssueSqlQueryTemplate);

            issue = db.Query<IssueViewModel>(issueTemplate.RawSql, issueTemplate.Parameters).SingleOrDefault();
            if (issue != null)
            {
                issue.Comments = CommentsForIssueUsingDb(issue.Id, db);

                QueryService.AssignAreasReleasesAndTypesToIssue(issue);
            }

            return issue != null;
        }
Exemplo n.º 6
0
 public static bool TryGetIssueWithComments(long issueId, out IssueViewModel issue)
 {
     using (var db = DataService.Connect(true))
     {
         return TryGetIssueWithCommentsUsingDb(issueId, db, out issue);
     }
 }