public void Details_return_correct_ParticipationInOlympiads_if_id_is_correct() { const int partInOlympId = 22; var partInOlympResult = new ParticipationInOlympiad(); //Arrange _queryBuilder .For <Task <ParticipationInOlympiad> >() .With( Arg.Is <GetCurrentParticipationInOlympiadCriterion>( p => p.EntrantId == EntrantId && p.ParticipationInOlympiadId == partInOlympId)) .Returns(Task.FromResult(partInOlympResult)); //Act var controller = new OlympiadController(_queryBuilder, _commandBuilder, _infoExtractor); controller.ControllerContext = new ControllerContext(_requestContext, controller); var task = controller.Details(partInOlympId); task.Wait(); var result = ((ViewResult)task.Result).Model; //Assert Assert.IsTrue(result == partInOlympResult); }
public async Task <ActionResult> Edit( [Bind(Include = "Id,Result")] ParticipationInOlympiad participationinolympiad) { //var entrantId = await _infoExtractor.ExtractEntrantId(User.Identity.GetUserId()); //participationinolympiad.EntrantId = entrantId; if (ModelState.IsValid) { await _commandBuilder .ExecuteAsync(new UpdateParticipationInOlympiadResultContext { ParticipationInOlympiadId = participationinolympiad.Id, UpdateResult = participationinolympiad.Result }); return(RedirectToAction("Index")); } return(View(participationinolympiad)); }
public async Task <ActionResult> Create( [Bind(Include = "Result,OlympiadId")] ParticipationInOlympiad participationinolympiad) { participationinolympiad.EntrantId = await _infoExtractor.ExtractEntrantId(User.Identity.GetUserId()); if (ModelState.IsValid) { await _commandBuilder .ExecuteAsync(new AddParticipationInOlympiadContext { ParticipationInOlympiad = participationinolympiad }); return(RedirectToAction("Index")); } var olympiads = await _queryBuilder .For <Task <IEnumerable <Olympiad> > >() .With(new GetAllOlympiadsCriterion()); ViewBag.OlympiadId = new SelectList(olympiads, "Id", "Name", participationinolympiad.OlympiadId); return(View(participationinolympiad)); }