コード例 #1
0
ファイル: IssueController.cs プロジェクト: ja1984/ProjectZ
        public ActionResult Comment(string comment, string projectId, int issueId)
        {
            var project = RavenSession.Load<Project>(projectId);
            var issue = project.Issues.FirstOrDefault(x => x.Id == issueId);

            var issueComment = new IssueComment
                                   {
                                       Id = issue.Comments.Count() + 1,
                                       Comment = comment,
                                       Posted = DateTime.Now,
                                       User = new IssueCommentUser(CurrentUser)
                                   };

            issue.Comments.Add(issueComment);

            var eventAction = new EventAction()
            {
                Action = Action.Comment,
                Created = DateTime.Now,
                ProjectId = projectId,
                Title = comment,
                ProjectName = project.Name,
                Url = string.Format("/{0}/{1}/issues/{2}#{3}", projectId, project.Slug, issue.Id, issueComment.Id),
                User = new EventActionUser(CurrentUser),
                Reference = new EventActionReference
                                {
                                    Id = issue.Id.ToString(),
                                    Name = issue.Title
                                }
            };
            RavenSession.Store(eventAction);
            RavenSession.SaveChanges();

            return Redirect(HttpContext.Request.UrlReferrer.ToString());
        }
コード例 #2
0
ファイル: ReleaseController.cs プロジェクト: ja1984/ProjectZ
        public JsonResult Create(CreateReleaseModel release)
        {
            var project = RavenSession.Load<Project>(release.ProjectId);

            if (!string.IsNullOrEmpty(release.Id))
            {
                Update(release);

                return Json(new { Success = true, Release = release });
            }

            var issues = new List<Issue>();
            if (release.SolvedIssues != null)
            {
                issues.AddRange(project.Issues.Where(x => release.SolvedIssues.Contains(x.Id)).ToList());

                foreach (var issue in issues)
                {
                    issue.Solved = true;
                }
            }

            var newRelease = new Release
            {
                Created = DateTime.Now,
                Description = release.Description,
                Issues = issues,
                ProjectId = release.ProjectId,
                Title = release.Title,
                Version = release.Version
            };

            var eventAction = new EventAction()
            {
                Action = Action.Release,
                Created = DateTime.Now,
                ProjectId = release.ProjectId,
                Title = release.Version,
                ProjectName = project.Name,
                Url = string.Format("/{0}/{1}/releases/{2}", release.ProjectId, project.Slug, release.Id),
                User = new EventActionUser(CurrentUser)
            };

            RavenSession.Store(eventAction);
            RavenSession.Store(newRelease);
            RavenSession.SaveChanges();

            return Json(new { Success = true, Release = newRelease });
        }
コード例 #3
0
ファイル: ProjectController.cs プロジェクト: ja1984/ProjectZ
        public JsonResult AddTeamMember(string projectId, string userId, bool isAdmin, Role role)
        {
            var project = RavenSession.Load<Project>(projectId);

            if (project == null)
                return Json(new { success = false, message = "Couldn´t find project" });

            if (project.Admins.Select(x => x.UserId).Contains(userId))
                return Json(new { success = false, message = "This user is already part of team" });

            var user = RavenSession.Load<User>(userId);

            if (user == null)
                return Json(new { success = false, message = "Couldn´t find user" });

            if (CurrentUser == null)
                return Json(new { success = false, message = "You are not admin of this project" });

            if (!project.Admins.Where(x => x.IsPageAdmin).Select(x => x.UserId).Contains(CurrentUser.Id))
                return Json(new { success = false, message = "You are not admin of this project" });

            user.Projects.Add(new UserProject(project));
            var teamMember = new TeamMember(user, role, isAdmin);
            project.Admins.Add(teamMember);

            var eventAction = new EventAction()
            {
                Action = Action.TeamMember,
                Created = DateTime.Now,
                ProjectId = projectId,
                ProjectName = project.Name,
                Title = user.UserName,
                Url = string.Format("/user/{0}", user.Slug),
                User = new EventActionUser(CurrentUser),
                Reference = new EventActionReference
                {
                    Id = project.Id,
                    Name = project.Name
                }
            };

            RavenSession.Store(eventAction);

            RavenSession.SaveChanges();

            return Json(new { success = true, message = "User added", User = teamMember });
        }
コード例 #4
0
ファイル: IssueController.cs プロジェクト: ja1984/ProjectZ
        public JsonResult Create(Issue issue, string projectId)
        {
            try
            {
                var project = RavenSession.Load<Project>(projectId);
                if (project == null)
                    return Json(new { success = false, message = "No project found" });

                if (CurrentUser == null)
                    return Json(new { success = false, message = "You are not logged in" });

                issue.User = new IssueUser(CurrentUser);
                issue.Votes.Add(new Vote { UserId = CurrentUser.Id });
                issue.Posted = DateTime.Now;
                issue.Id = project.Issues.Count() + 1;
                project.Issues.Add(issue);

                var eventAction = new EventAction()
                               {
                                   Action = issue.IssueType == IssueType.Feature ? Action.Feature : Action.Bug,
                                   Created = DateTime.Now,
                                   ProjectId = projectId,
                                   Title = issue.Title,
                                   ProjectName = project.Name,
                                   Url = string.Format("/{0}/{1}/issues/{2}", projectId, project.Slug, issue.Id),
                                   User = new EventActionUser(CurrentUser)
                               };
                RavenSession.Store(eventAction);
                RavenSession.SaveChanges();

                return Json(new { success = true, message = issue.Id });
            }
            catch
            {
                return Json(new { success = false, message = "Error" });

            }
        }
コード例 #5
0
ファイル: ProjectController.cs プロジェクト: ja1984/ProjectZ
        public JsonResult CreatePoll(string projectId, Poll poll)
        {
            var project = RavenSession.Load<Project>(projectId);

            poll.Id = project.Polls.Count() + 1;

            var eventAction = new EventAction()
            {
                Action = Action.Poll,
                Created = DateTime.Now,
                ProjectId = projectId,
                Title = poll.Title,
                ProjectName = project.Name,
                Url = string.Format("/{0}/{1}/polls", projectId, project.Slug),
                User = new EventActionUser(CurrentUser),
                Reference = new EventActionReference
                                {
                                    Id = project.Id,
                                    Name = project.Name
                                }
            };
            RavenSession.Store(eventAction);

            project.Polls.Add(poll);
            RavenSession.SaveChanges();

            return Json(new { success = true });
        }