private async void Delete() { using (var context = InMemoryDb.CreateDbContext()) { context.Initialize(); var service = new SampleFramesService(context, null); var userId = (await context.Users.FirstAsync()).Id; await service.Create( new SampleFrameM { Predicate = CreateExpressionGroup(), Name = "Sample frame name", Fields = new[] { FieldEnum.Address } }, userId ); Assert.Equal(1, await context.SampleFrames.CountAsync()); await service.Delete((await context.SampleFrames.FirstOrDefaultAsync()).Id, userId); Assert.Equal(0, await context.SampleFrames.CountAsync()); } }
public async Task <IActionResult> DeleteAsync(int id) { await _sampleFramesService.Delete(id, User.GetUserId()); return(NoContent()); }