コード例 #1
0
        public void LoadProblemWithId()
        {
            var members = _session.List <Member>(3).Get();

            _conn.Collection <Member>(CollectionNames.Member).InsertBatch(members);

            var responses = _session.List <Response>(5)
                            .Random(3).Impose(x => x.UserId, members[0].Id)
                            .Next(1).Impose(x => x.UserId, members[1].Id)
                            .Next(1).Impose(x => x.UserId, members[2].Id)
                            .All().Get();

            var problem = _session.Single <Problem>()
                          .Impose(x => x.Responses, responses)
                          .Impose(x => x.UserId, members[0].Id)
                          .Get();

            _problemCollection.Save(problem);

            var fromDb = _problemRepository.Get(problem.Id.ToString());

            Assert.That(fromDb, Is.Not.Null);
            Assert.That(new ObjectId(fromDb.Id), Is.EqualTo(problem.Id));
            Assert.That(fromDb.Submitter.Id, Is.EqualTo(problem.UserId));
            Assert.That(fromDb.Responses.Count, Is.EqualTo(responses.Count));
        }
コード例 #2
0
 private SubtaskVM ConvertToSubtaskVM(Subtask subtask)
 {
     return(new SubtaskVM()
     {
         Id = subtask.Id,
         ProblemId = subtask.ProblemId,
         Problem = _problemRep.Get(subtask.ProblemId).Summary,
         Summary = subtask.Summary,
         Description = subtask.Description,
         Reporter = _userRep.GetById(subtask.ReporterId).Name,
         AssigneeId = subtask.AssigneeId,
         Assignee = _userRep.GetById(subtask.AssigneeId).Name,
         EstimatedTime = subtask.EstimatedTime,
         RemainingTime = subtask.RemainingTime
     });
 }
コード例 #3
0
        public void OnGet()
        {
            int pageIndex;

            //未输入页码时默认显示第一页
            if (Request.Query["page"].Count == 0)
            {
                pageIndex = 1;
            }
            else
            {
                pageIndex = Convert.ToInt32(Request.Query["page"][0]);
            }
            ProblemRepository repository = new ProblemRepository();

            problems   = repository.Get(pageIndex, pageSize);
            pageAmount = (repository.CountOfProblem() / pageSize) + 1;
        }
コード例 #4
0
        public void OnGet()
        {
            string exclude = Request.Query["exclude"];

            if (string.IsNullOrEmpty(exclude))
            {
                Problems = _problem.Get();
            }
            else
            {
                Problems = _problem.GetExclude(Enum.Parse <ProblemStatus>(exclude));
            }



            int pageIndex = Convert.ToInt32(Request.RouteValues["id"]);
            int pageSize  = 2;

            Problems     = Problems.GetPage(pageSize, pageIndex);
            SumOfArticle = _problem.GetSum();
        }
コード例 #5
0
 public IEnumerable <Problem> Get()
 {
     return(_repo.Get());
 }
コード例 #6
0
 public ProblemVM Get(int id)
 {
     return(ConvertToProblemVM(_problemRep.Get(id)));
 }
コード例 #7
0
        public Problem GetProblemById(int id)
        {
            ProblemRepository problem = new ProblemRepository(Startup.connectionString);

            return(problem.Get(id));
        }