private void SetUserEditPermissionsForIssue(IssueDetailVM issueVm)
 {
     if (userSessionHelper.UserId > 0)
     {
         var teamMember = teamRepository.GetTeamMember(issueVm.TeamID, userSessionHelper.UserId);
         issueVm.IsEditableForCurrentUser = teamMember != null;
     }
 }
Esempio n. 2
0
        public CreateIssue(IssueDetailVM issueDetail)
        {
            this.Title            = issueDetail.Title;
            this.Description      = issueDetail.Description;
            this.SelectedProject  = issueDetail.Project.Id;
            this.SelectedStatus   = issueDetail.Status.Id;
            this.SelectedCategory = issueDetail.Category.Id;
            this.SelectedPriority = issueDetail.Priority.Id;


            this.Statuses   = new List <SelectListItem>();
            this.Categories = new List <SelectListItem>();
            this.Projects   = new List <SelectListItem>();
            this.Priorities = new List <SelectListItem>();
        }
        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.ObjectTite = 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.ObjectTite = 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.ObjectTite = newVersion.Title;
                    isStateChanged = true;
                }


            }

            activity.TeamId = userSessionHelper.TeamId;

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

            if (isStateChanged)
            {
                var newId = activityRepository.Save(activity);
                return activityRepository.GetActivityItem(newId);

            }
            return null;
        }
Esempio n. 4
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
            }
        }
        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;
        }
 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);
 }
        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");
            }
        }
        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;
                }
            }
        }
        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);
            }*/
        }
Esempio n. 10
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 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 async Task<IActionResult> Details(int id)
 {
     var vm = new IssueDetailVM();
     vm = await this._issueManager.GetIssue(id);
     if (vm != null && vm.Active)
     {
         vm.IsEditableForCurrentUser = this._teamManager.DoesCurrentUserBelongsToTeam(this._userSessionHelper.UserId, this._userSessionHelper.TeamId);
         vm.IsReadOnly = this._userSessionHelper.UserId == 0;
         return View(vm);
     }
     return View("NotFound");
 }
Esempio n. 13
0
        public CreateIssue(IssueDetailVM issueDetail)
        {
            this.Title = issueDetail.Title;
            this.Description = issueDetail.Description;
            this.ProjectId = issueDetail.Project.Id;
            this.StatusId = issueDetail.Status.Id;
            this.CategoryId = issueDetail.Category.Id;
            this.PriorityId = issueDetail.Priority.Id;


            this.Statuses = new List<SelectListItem>();
            this.Categories = new List<SelectListItem>();
            this.Projects = new List<SelectListItem>();
            this.Priorities = new List<SelectListItem>();

        }