Example #1
0
 private void SetUserEditPermissionsForIssue(IssueDetailVM issueVm)
 {
     if (userSessionHelper.UserId > 0)
     {
         var teamMember = teamRepository.GetTeamMember(issueVm.TeamID, userSessionHelper.UserId);
         issueVm.IsEditableForCurrentUser = teamMember != null;
     }
 }
        public async Task <IActionResult> Members(int id)
        {
            var issue = new IssueDetailVM();

            issue.IsEditableForCurrentUser = this._teamManager.DoesCurrentUserBelongsToTeam(this._userSessionHelper.UserId, this._userSessionHelper.TeamId);
            var members = await _issueManager.GetIssueMembers(id);

            issue.Members = members.Select(x => x.Member);
            return(PartialView("Partial/Members", issue));
        }
        public ActionResult IssueMembers(int id)
        {
            var vm = new IssueDetailVM {
                Id = id
            };

            issueService.LoadIssueMembers(id, vm, UserID);
            issueService.SetUserPermissionsForIssue(vm, UserID, TeamID);
            return(PartialView("Partial/Members", vm));
        }
Example #4
0
 public void SetUserPermissionsForIssue(IssueDetailVM issueVm, int currentUserId = 0, int teamId = 0)
 {
     if (currentUserId > 0)
     {
         var teamMember = repo.GetTeamMember(currentUserId, teamId);
         if (teamMember != null)
         {
             issueVm.IsEditableForCurrentUser = true;
         }
     }
 }
Example #5
0
        public async Task <IActionResult> Members(int id)
        {
            var issue = new IssueDetailVM();

            issue.IsEditableForCurrentUser = this.teamManager.DoesCurrentUserBelongsToTeam();
            var members = await issueManager.GetIssueMembers(id);

            issue.Members = members;



            return(PartialView("Partial/Members", issue));
        }
Example #6
0
        public IActionResult Details(int id)
        {
            var vm = new IssueDetailVM();

            vm = this.issueManager.GetIssue(id);
            if (vm != null && vm.Active)
            {
                vm.IsEditableForCurrentUser = this.teamManager.DoesCurrentUserBelongsToTeam();
                vm.IsReadOnly = this.userSessionHelper.UserId == 0;
                return(View(vm));
            }
            return(View("NotFound"));
        }
Example #7
0
        public IssueVM GetIssueVM(Issue bug)
        {
            var issueVM = new IssueDetailVM {
                ID = bug.ID, Title = bug.Title, Description = bug.Description
            };

            issueVM.OpenedBy     = bug.CreatedBy.FirstName;
            issueVM.PriorityName = bug.Priority.Name;
            issueVM.StatusName   = bug.Status.Name;
            issueVM.CategoryName = bug.Category.Name;
            issueVM.ProjectName  = (bug.Project != null?bug.Project.Name:"");
            issueVM.CreatedDate  = bug.CreatedDate;
            return(issueVM);
        }
        public ActivityDto SaveActivity(CreateIssue model, IssueDetailVM previousVersion, IssueDetailVM newVersion)
        {
            bool isStateChanged = false;
            var  activity       = new ActivityDto()
            {
                ObjectId = newVersion.Id, ObjectType = "Issue"
            };

            if (previousVersion == null)
            {
                activity.ObjectUrl = "issue/" + newVersion.Id;
                //activity.CreatedBy =
                activity.Description = "Created";
                activity.ObjectTitle = model.Title;
                isStateChanged       = true;
            }
            else
            {
                if (previousVersion.Status.Id != newVersion.Status.Id)
                {
                    // status of issue updated
                    activity.Description = "Changed status";
                    activity.NewState    = newVersion.Status.Name;
                    activity.OldState    = previousVersion.Status.Name;
                    activity.ObjectTitle = newVersion.Title;
                    isStateChanged       = true;
                }
                else if (previousVersion.Category.Id != newVersion.Category.Id)
                {
                    activity.Description = "Changed category";
                    activity.NewState    = newVersion.Category.Name;
                    activity.OldState    = previousVersion.Category.Name;
                    activity.ObjectTitle = newVersion.Title;
                    isStateChanged       = true;
                }
            }
            activity.CreatedTime = DateTime.Now;
            activity.TeamId      = userSessionHelper.TeamId;

            activity.Actor = new UserDto {
                Id = userSessionHelper.UserId
            };

            if (isStateChanged)
            {
                var newId = activityRepository.Save(activity);
                return(activityRepository.GetActivityItem(newId));
            }
            return(null);
        }
        public IssueDetailVM GetIssue(int id)
        {
            using (var db = new TeamEntitiesConn())
            {
                var issue = db.Issues.FirstOrDefault(s => s.ID == id);
                if (issue != null)
                {
                    var issueDto = new IssueDetailVM
                    {
                        ID          = issue.ID,
                        Title       = issue.Title,
                        Description = issue.Description ?? string.Empty,
                        Author      = new UserDto {
                            Id = issue.CreatedBy.ID, Name = issue.CreatedBy.FirstName
                        },
                        Project = new KeyValueItem {
                            Id = issue.Project.ID, Name = issue.Project.Name
                        },
                        TeamID = issue.TeamID,
                        Status = new KeyValueItem {
                            Id = issue.Category.ID, Name = issue.Status.Name
                        },
                        CreatedDate = issue.CreatedDate,
                        Category    = new KeyValueItem {
                            Id = issue.Category.ID, Name = issue.Category.Name
                        },
                        StatusGroupCode = issue.Status.StatusGroup.Code
                    };
                    if (issue.Priority != null)
                    {
                        issueDto.Priority = new KeyValueItem {
                            Id = issue.Priority.ID, Name = issue.Priority.Name
                        };
                    }


                    if (issue.ModifiedDate.HasValue && issue.ModifiedDate.Value > DateTime.MinValue && issue.ModifiedBy != null)
                    {
                        issueDto.LastModifiedDate = issue.ModifiedDate.Value.ToString("g");
                        issueDto.LastModifiedBy   = issue.ModifiedBy.FirstName;
                    }

                    return(issueDto);
                }
            }
            return(null);
        }
Example #10
0
        public async Task SendIssueCreatedEmail(IssueDetailVM issue, int teamId)
        {
            try
            {
                var subscibers = await _teamRepository.GetSubscribers(teamId, "NewIssue");

                if (subscibers.Any())
                {
                    var emailTemplate = await _emailRepository.GetEmailTemplate("NewIssue");

                    if (emailTemplate != null)
                    {
                        var emailSubject = emailTemplate.Subject;
                        var emailBody    = emailTemplate.EmailBody;
                        var email        = new Email();


                        foreach (var subsciber in subscibers)
                        {
                            email.ToAddress.Add(subsciber.EmailAddress);
                        }
                        var team = _teamRepository.GetTeam(teamId);

                        var issueUrl  = this._settings.SiteUrl + "/issues/" + issue.Id;
                        var issueLink = string.Format("<a href='{0}'>" + "#{1} {2}</a>", issueUrl, issue.Id, issue.Title);

                        emailBody    = emailBody.Replace("@issueAuthor", issue.Author.Name);
                        emailBody    = emailBody.Replace("@teamName", team.Name);
                        emailBody    = emailBody.Replace("@issueLink", issueLink);
                        emailSubject = emailSubject.Replace("@teamName", team.Name);

                        email.Body    = emailBody;
                        email.Subject = emailSubject;
                        await Send(email);
                    }
                }
            }
            catch (Exception)
            {
                // Silently fail. We will log this. But we do not want to show an error to user because of this
            }
        }
Example #11
0
        public void LoadIssueMembers(int id, IssueDetailVM issueVm, int currentUserId = 0)
        {
            var issueMemberRelations = repo.GetIssueMembers(id);

            //check the current user has starred the issue
            if (currentUserId != 0)
            {
                var isCurrentUserStarredIssue = issueMemberRelations.Where(s => s.RelationType == IssueMemberRelationType.Star.ToString() && s.MemberID == currentUserId).FirstOrDefault();
                issueVm.IsStarredForUser = isCurrentUserStarredIssue != null;
            }

            /**
             * //Now get the members assigned to this issue
             * var issueMemberList = issueMemberRelations.Where(s => s.RelationType ==IssueMemberRelationType.Member.ToString());
             * foreach (var member in issueMemberList)
             * {
             *  var vm = new MemberVM { MemberType = member.Member.JobTitle, Name = member.Member.FirstName, MemberID = member.MemberID };
             *  vm.AvatarHash = UserService.GetImageSource(member.Member.EmailAddress);
             *  issueVm.Members.Add(vm);
             * }*/
        }
        public ActionResult Details(int id = 0, int commentId = 0)
        {
            int issueId = 0;

            try
            {
                if (id > 0)
                {
                    issueId = id;
                }
                else if (id == 0 && commentId > 0)
                {
                    issueId = repo.GetComment(commentId).IssueID;
                }

                var bug = repo.GetIssue(issueId);

                if (bug == null || TeamID != bug.TeamID)
                {
                    return(View("NotFound"));
                }


                IssueDetailVM bugVm = new IssueDetailVM {
                    Id = bug.ID, Title = bug.Title
                };

                bugVm = issueManager.GetIssue(id);

                //bugVm.Description = (bug.Description == null ? "" : bug.Description.ConvertUrlsToLinks());
                //bugVm.CreatedDate = bug.CreatedDate;
                //bugVm.OpenedBy = bug.CreatedBy.FirstName;
                //bugVm.Title = bug.Title;
                //bugVm.Project = bug.Project.Name;
                //bugVm.CategoryName = bug.Category.Name;
                //bugVm.ProjectID = bug.ProjectID;
                //bugVm.TeamID = bug.TeamID;
                //bugVm.StatusName = bug.Status.Name;
                //bugVm.PriorityName = bug.Priority.Name;
                //bugVm.StatusCode = bug.Status.Name;
                //if (bug.ModifiedDate.HasValue && bug.ModifiedDate.Value > DateTime.MinValue && bug.ModifiedBy != null)
                //{
                //    bugVm.LastModifiedDate = bug.ModifiedDate.Value.ToString("g");
                //    bugVm.LastModifiedBy = bug.ModifiedBy.FirstName;
                //}


                if (bug.DueDate.HasValue)
                {
                    bugVm.IssueDueDate = (bug.DueDate.Value.Year > 2000 ? bug.DueDate.Value.ToShortDateString() : "");
                }

                var allDocuments = repo.GetDocuments(issueId);
                foreach (var img in allDocuments)
                {
                    var imgVM = new DocumentVM {
                        FileName = img.FileName, FileKey = img.FileAlias
                    };
                    imgVM.FileExtn = Path.GetExtension(img.FileName);

                    if (imgVM.FileExtn.ToUpper() == ".JPG" || imgVM.FileExtn.ToUpper() == ".PNG")
                    {
                        bugVm.Images.Add(imgVM);
                    }
                    else
                    {
                        bugVm.Attachments.Add(imgVM);
                    }
                }

                //Get Members
                //issueService.LoadIssueMembers(issueId, bugVm, UserID);

                // issueService.SetUserPermissionsForIssue(bugVm, UserID, TeamID);
                return(View(bugVm));
            }
            catch (Exception ex)
            {
                log.Error("error loading issue " + issueId, ex);
                return(View("Error"));
            }
        }