protected override ValueTask <HealthCheckResult> CheckAsync(CancellationToken cancellationToken = default(CancellationToken)) { bool success = false; if (_context == null || _apiController == null) { return(new ValueTask <HealthCheckResult>(HealthCheckResult.Unhealthy(MESSAGE))); } // GET api/scoredname var getAllResult = _apiController.GetAll(); success = (getAllResult != null && getAllResult.Count() >= 0); // GET api/scoredname/{id} var dummy = createDummyName(); _context.ScoredNames.Add(dummy); _context.SaveChanges(); var getbyIdresult = _apiController.GetById(_context.ScoredNames.First().Id); success &= getbyIdresult != null; _context.ScoredNames.Remove(dummy); _context.SaveChanges(); // POST api/scoredname // TODO: add a POST check here if (success) { return(new ValueTask <HealthCheckResult>(HealthCheckResult.Healthy(MESSAGE))); } return(new ValueTask <HealthCheckResult>(HealthCheckResult.Degraded(MESSAGE))); }
public IActionResult Create([FromBody] JArray jsonArray) { IEnumerable <ScoredName> scoredNames = jsonArray.ToObject <List <ScoredName> >(); _context.ScoredNames.AddRange(scoredNames); _context.SaveChanges(); return(Ok()); }