public void Given_Group_When_DeleteGroupAsync_Then_ShouldBeTrue() { RunOnDatabase(context => { // ARRANGE context.Roles.Add(Role.Create("student")); context.SaveChanges(); var userType = context.Roles.FirstOrDefault(); if (userType != null) { var user = User.Create( "User first name", "User last name", "User", "*****@*****.**", "parola" ); context.Users.Add(user); } context.SaveChanges(); var userId = context.Users.FirstOrDefault(); var groupRepository = new GroupsRepository(context); if (userId == null) { return; } var group = Group.Create( "A2", "grupa din anul III", userId.Id ); context.Add(@group); context.SaveChanges(); // ACT var result = groupRepository.DeleteAsync(@group.Id); // ASSERT result.Result.Should().Be(true); }); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Group = await repository.GetSingleAsync(id.Value); if (Group != null) { await repository.DeleteAsync(id.Value); } return(RedirectToPage("./Index")); }
public async Task <ActionResult> Delete(int id) { await repository.DeleteAsync(id); return(Ok()); }