public async Task <ActionResult <GidHelper> > SearchGidHelpers(string searchText) { GidHelper currentGidHelper = null; var results = await _context.GidHelpers.ToListAsync(); foreach (var result in results) { if (result.Question.ToLower().Contains(searchText.ToLower())) { currentGidHelper = result; break; } if (Levenshtein.Distance(result.Question.ToLower(), searchText.ToLower()) < 10) { currentGidHelper = result; break; } } if (currentGidHelper == null) { return(new GidHelper()); } return(currentGidHelper); }
public async Task <IActionResult> PutGidHelper(int id, GidHelper gidHelper) { if (id != gidHelper.Id) { return(BadRequest()); } _context.Entry(gidHelper).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GidHelperExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <GidHelper> > PostGidHelper(GidHelper gidHelper) { _context.GidHelpers.Add(gidHelper); await _context.SaveChangesAsync(); return(CreatedAtAction("GetGidHelper", new { id = gidHelper.Id }, gidHelper)); }