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)); }
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 }); }
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; }
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(); }
public IEnumerable <Problem> Get() { return(_repo.Get()); }
public ProblemVM Get(int id) { return(ConvertToProblemVM(_problemRep.Get(id))); }
public Problem GetProblemById(int id) { ProblemRepository problem = new ProblemRepository(Startup.connectionString); return(problem.Get(id)); }