// To protect from overposting attacks, enable the specific properties you want to bind to. // For more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } await _useCase.HandleAsync(StudentGroup); return(RedirectToPage("./Index")); }
public async Task Cannot_update_non_existing_group() { var request = new GroupUpdate.Request { Id = 1, Name = "S3 - Timo", }; var useCase = new GroupUpdate(new ProgressContext(Fixture.ContextOptions)); var result = await useCase.HandleAsync(request); result.IsFailure.Should().BeTrue(); result.Error.Should().Contain("exist"); }
public async Task Can_update_group() { var group = Fixture.DataMother.CreateGroup(); var request = new GroupUpdate.Request { Id = group.Id, Name = "S3 - Timo", StartDate = new DateTime(2021, 9, 1), Mnemonic = "Denk hier aan!" }; var useCase = new GroupUpdate(new ProgressContext(Fixture.ContextOptions)); var result = await useCase.HandleAsync(request); result.IsSuccess.Should().BeTrue(); var groupUpdated = Fixture.DataMother.Query <StudentGroup>(); groupUpdated .ShouldExist() .HasName("S3 - Timo") .HasPeriod((Period) new DateTime(2021, 9, 1)) .HasMnemonic("Denk hier aan!"); }