コード例 #1
0
        public ActionResult GetLogItems(int iDisplayStart, int iDisplayLength, string sEcho, string sSearch)
        {
            int totalResults;
            var results = Context.Logs.Search(iDisplayStart, iDisplayLength, sSearch, out totalResults).ToList();

            var model = new DataTablePage
            {
                sEcho = sEcho,
                iTotalRecords = totalResults,
                iTotalDisplayRecords = totalResults
            };

            foreach (var log in results)
            {
                var item = new Dictionary<string, string>
                    {
                        {"Message", log.Message},
                        {"DT_RowId", "roleItem_" + log.Id}
                    };

                model.aaData.Add(item);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #2
0
        public ActionResult GetProjectItems(int iDisplayStart, int iDisplayLength, string sEcho, string sSearch)
        {
            int totalRecords;
            var query = Context.Projects.Search(iDisplayStart, iDisplayLength, sSearch, out totalRecords);

            var projects = (from x in query.Where(x => !x.IsEnded)
                            select new ProjectModel
                            {
                                Id = x.Id,
                                Name = x.Name
                            }).ToList();

            var model = new DataTablePage
            {
                sEcho = sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords
            };

            foreach (var project in projects)
            {
                var item = new Dictionary<string, string>
                    {
                        {"Name", project.Name},
                        {"DT_RowId", "roleItem_" + project.Id}
                    };

                model.aaData.Add(item);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
        public ActionResult GetBacklogItems(int iDisplayStart, int iDisplayLength, string sEcho)
        {
            int totalRecords;
            var stories = ProjectContext.GetBacklogItems(iDisplayStart, iDisplayLength, out totalRecords).ToList();

            var model = new DataTablePage
            {
                sEcho = sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords
            };

            foreach (var story in stories)
            {
                var item = new Dictionary<string, string>
                {
                    {"Summary", story.Summary},
                    {"Reporter", story.Reporter.Name},
                    {"Type", story.Type.GetDescription()},
                    {"StoryPoints", story.StoryPoints.ToString()},
                    {"Priority", story.Priority.ToString()},
                    {"DT_RowId", "backlogItem_" + story.Id}
                };

                model.aaData.Add(item);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #4
0
        public ActionResult GetBackupRequestItems(int iDisplayStart, int iDisplayLength, string sEcho)
        {
            using (var context = new DatabaseContext())
            {
                var query = context.BackupRequests.OrderByDescending(x => x.CreatedDate);

                var totalRecords = query.Count();

                var page = query.Skip(iDisplayStart).Take(iDisplayLength).ToList();

                var model = new DataTablePage
                {
                    sEcho = sEcho,
                    iTotalRecords = totalRecords,
                    iTotalDisplayRecords = totalRecords
                };

                var backupRequests = (from x in page
                             select new BackupRequestModel
                             {
                                 Path = x.Path,
                                 Schedule = x.Schedule,
                                 State = x.State,
                                 Type = x.Type,
                                 CreatedDate = x.CreatedDate
                             }).ToList();

                foreach (var backup in backupRequests)
                {
                    var item = new Dictionary<string, string>
                    {
                        {"Path", backup.Path},
                        {"Schedule", backup.Schedule.ToString()},
                        {"State", backup.State.ToString()},
                        {"Type", backup.Type.ToString()},
                        {"CreatedDate", backup.CreatedDate.ToString()},
                        {"DT_RowId", "roleItem_" + backup.Id}
                    };

                    model.aaData.Add(item);
                }

                return Json(model, JsonRequestBehavior.AllowGet);
            }
        }
コード例 #5
0
ファイル: UserController.cs プロジェクト: hveiras/TeamMashup
        public ActionResult GetUserItems(int iDisplayStart, int iDisplayLength, string sEcho)
        {
            var query = Context.Users.NonDeleted().OrderByDescending(x => x.CreatedDate);

            var totalRecords = query.Count();

            var page = query.Skip(iDisplayStart).Take(iDisplayLength).ToList();

            var model = new DataTablePage
            {
                sEcho = sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords
            };

            var users = (from x in page
                         select new UserModel
                         {
                             Id = x.Id,
                             Name = x.Name,
                             Email = x.Email
                         }).ToList();

            foreach (var user in users)
            {
                var item = new Dictionary<string, string>
                    {
                        {"Name", user.Name},
                        {"Email", user.Email},
                        {"DT_RowId", "userItem_" + user.Id}
                    };

                model.aaData.Add(item);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #6
0
        public ActionResult GetIterations(long releaseId, int iDisplayStart, int iDisplayLength, string sEcho)
        {
            var query = ProjectContext.Iterations
                               .AsPredicateTrue()
                               .And(x => x.ReleaseId == releaseId)
                               .And(x => !x.Deleted)
                               .Evaluate()
                               .OrderByDescending(x => x.CreatedDate);

            var page = query.GetPage(iDisplayStart, iDisplayLength);

            var model = new DataTablePage
            {
                sEcho = sEcho,
                iTotalRecords = page.TotalItems,
                iTotalDisplayRecords = page.TotalItems
            };

            foreach (var item in page.Items.Select(iteration => new Dictionary<string, string>
            {
                {"Name", iteration.Name },
                {"State", iteration.State.GetDescription() },
                {"From", iteration.From.ToShortDateString() },
                {"To", iteration.To.ToShortDateString() },
                {"DT_RowId", "release_" + iteration.Id}
            }))
            {
                model.aaData.Add(item);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #7
0
ファイル: WorkController.cs プロジェクト: hveiras/TeamMashup
        public ActionResult GetIterationIssues(long iterationId, ScheduleState state, int iDisplayStart, int iDisplayLength, string sEcho)
        {
            var query = ProjectContext.Issues
                               .AsPredicateTrue()
                               .And(x => x.IterationId == iterationId)
                               .And(x => x.StateValue == (int)state)
                               .And(x => !x.Deleted)
                               .Evaluate()
                               .OrderByDescending(x => x.CreatedDate);

            var page = query.GetPage(iDisplayStart, iDisplayLength);

            var model = new DataTablePage
            {
                sEcho = sEcho,
                iTotalRecords = page.TotalItems,
                iTotalDisplayRecords = page.TotalItems
            };

            foreach (var issue in page.Items)
            {
                var item = new Dictionary<string, string>
                {
                    {"Summary", issue.Summary},
                    {"Reporter", issue.Reporter.Name},
                    {"Type", issue.Type.GetDescription()},
                    {"StoryPoints", issue.StoryPoints.ToString()},
                    {"Priority", issue.Priority.ToString()},
                    {"DT_RowId", "issue_" + issue.Id},
                    {"DT_RowClass", "row-" + issue.Type.ToString().ToLower()}
                };

                model.aaData.Add(item);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #8
0
        public ActionResult GetIterationIssues(long iterationId, int iDisplayStart, int iDisplayLength, string sEcho)
        {
            var pc = ProjectContext;

            Iteration iteration;
            if (!pc.Iterations.TryGetById(iterationId, out iteration))
                throw new ApplicationException("Iteration with id = " + iterationId + " was not found!");

            int totalRecords = iteration.UserStoriesNonDeleted.Count;
            var model = new DataTablePage
            {
                sEcho = sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords
            };

            foreach (var story in iteration.UserStoriesNonDeleted)
            {
                var item = new Dictionary<string, string>
                {
                    {"Name", story.Summary},
                    {"Reporter", story.Reporter.Name },
                    {"Type", story.Type.ToString()},
                    {"StoryPoints", story.StoryPoints.ToString()},
                    {"Priority", story.Priority.ToString()},
                    {"DT_RowId", "backlogItem_" + story.Id}
                };

                model.aaData.Add(item);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #9
0
        public ActionResult GetLanguageItems(int iDisplayStart, int iDisplayLength, string sEcho)
        {
            var query = Context.Languages.OrderByDescending(x => x.Name);

            var totalRecords = query.Count();

            var page = query.Skip(iDisplayStart).Take(iDisplayLength).ToList();

            var model = new DataTablePage
            {
                sEcho = sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords
            };

            var languages = (from x in page
                             select new LanguageModel
                             {
                                 Id = x.Id,
                                 Name = x.Name,
                                 Code = x.Code
                             }).ToList();

            foreach (var language in languages)
            {
                var item = new Dictionary<string, string>
                    {
                        {"Name", language.Name},
                        {"Code", language.Code},
                        {"DT_RowId", "roleItem_" + language.Id}
                    };

                model.aaData.Add(item);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #10
0
        public ActionResult GetSurveyOptionsItems(long surveyId, int iDisplayStart, int iDisplayLength, string sEcho)
        {
            Survey survey;
            if(!Context.Surveys.TryGetById(surveyId, out survey))
                throw new InvalidOperationException("survey with id = " + surveyId + " was not found!");

            var query = survey.Options.OrderByDescending(x => x.Votes);

            var totalRecords = query.Count();

            var page = query.Skip(iDisplayStart).Take(iDisplayLength).ToList();

            var model = new DataTablePage
            {
                sEcho = sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords
            };

            var options = (from x in page
                           select new SurveyItemModel
                           {
                               Id = x.Id,
                               Description = x.Description,
                               Votes = x.Votes
                           }).ToList();

            foreach (var option in options)
            {
                var item = new Dictionary<string, string>
                    {
                        {"Description", option.Description},
                        {"Votes", option.Votes.ToString()},
                        {"DT_RowId", "roleItem_" + option.Id}
                    };

                model.aaData.Add(item);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #11
0
        public ActionResult GetSurveyItems(int iDisplayStart, int iDisplayLength, string sEcho)
        {
            var query = Context.Surveys.OrderByDescending(x => x.CreatedDate);

            var totalRecords = query.Count();

            var page = query.Skip(iDisplayStart).Take(iDisplayLength).ToList();

            var model = new DataTablePage
            {
                sEcho = sEcho,
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalRecords
            };

            var surveys = (from x in page
                           select new SurveyModel
                           {
                               Id = x.Id,
                               Title = x.Title
                           }).ToList();

            foreach (var survey in surveys)
            {
                var item = new Dictionary<string, string>
                    {
                        {"Title", survey.Title},
                        {"DT_RowId", "roleItem_" + survey.Id}
                    };

                model.aaData.Add(item);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #12
0
        public ActionResult GetRoleItems(AssetScope scope, int iDisplayStart, int iDisplayLength, string sEcho)
        {
            using (var context = new DatabaseContext())
            {
                var query = context.Roles.Where(x => x.ScopeValue == (int)scope)
                                         .OrderByDescending(x => x.Name);

                var totalRecords = query.Count();

                var page = query.Skip(iDisplayStart).Take(iDisplayLength).ToList();

                var model = new DataTablePage
                {
                    sEcho = sEcho,
                    iTotalRecords = totalRecords,
                    iTotalDisplayRecords = totalRecords
                };

                var roles = (from x in page
                             select new RoleModel
                             {
                                 Id = x.Id,
                                 Name = x.Name
                             }).ToList();

                foreach (var role in roles)
                {
                    var item = new Dictionary<string, string>
                    {
                        {"Name", role.Name},
                        {"DT_RowId", "roleItem_" + role.Id}
                    };

                    model.aaData.Add(item);
                }

                return Json(model, JsonRequestBehavior.AllowGet);
            }
        }