public ActionResult Answer(ResponseModel model) { var member = _memberRepository.Get(MemberInformations.OpenId); if (member == null) { ViewData["Error"] = "There is no known user."; return(Redirect("/Login.aspx")); } _problemService.AddResponse(model.ProblemId, model.Text, member); return(RedirectToAction("Details", new { id = model.ProblemId })); }
public void AddResponseToProblem() { var member = _session.Single <Member>().Get(); _conn.Collection <Member>(CollectionNames.Member).Save(member); var problem = _problemService.CreateProblem("Problem 3244", "Some description", member); var stringSource = new RandomStringSource(5, 20); for (int i = 0; i < 10; i++) { _problemService.AddResponse(problem.Id.ToString(), stringSource.Next(_session), member); } // Get responses from db and check them. var fromDb = _problemCollection.AsQueryable().Where(p => p.Id == problem.Id).First(); Assert.That(fromDb.Responses.Count, Is.EqualTo(10)); for (int i = 0; i < 10; i++) { Assert.That(fromDb.Responses[i].UserId, Is.EqualTo(member.Id)); } }