Ejemplo n.º 1
0
        public async Task <IActionResult> AddSample([FromServices] SpamDetectorDbContext context, string message, bool isSpam)
        {
            context.SpamRecords.Add(new SpamRecord()
            {
                Message = message, IsSpam = isSpam
            });
            await context.SaveChangesAsync();

            return(Ok());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> RemoveSample([FromServices] SpamDetectorDbContext context, int id)
        {
            var spamRecord = await context.SpamRecords.SingleOrDefaultAsync(x => x.Id == id);

            if (spamRecord == null)
            {
                return(NotFound($"Spam record with id {id} not found."));
            }
            context.SpamRecords.Remove(spamRecord);
            await context.SaveChangesAsync();

            return(Ok());
        }
Ejemplo n.º 3
0
 public DbModelManager(SpamDetectorDbContext context)
 {
     _context = context;
 }
Ejemplo n.º 4
0
 public async Task <ActionResult <List <SpamRecord> > > GetAllRecords([FromServices] SpamDetectorDbContext context)
 {
     return(Ok(await context.SpamRecords.ToListAsync()));
 }
Ejemplo n.º 5
0
 public DataLoader(SpamDetectorDbContext dbContext, MLContext mlContext)
 {
     _dbContext = dbContext;
     _mlContext = mlContext;
 }