public async Task GetAllThings(IHttpContext context) { Authenticator.VerifyAuth(context); var payload = await Dispatcher.RunOnMainThread(() => ThingsModel.GetThings()); await context.SendResponse(HttpStatusCode.OK, payload); }
public void GivenColloctionWithSampleDocument() { _collection = ConnectionHelper.Connection <ThingsModel>("ThingsModel"); _id = Guid.NewGuid(); var t = new ThingsModel { _id = _id, IsActive = true }; _collection.InsertOne(t); }
public async Task PostThing(IHttpContext context, long referenceId, ThingPayload body) { Authenticator.VerifyAuth(context); var response = await Dispatcher.RunOnMainThread(() => ThingsModel.UpdateThing(referenceId, body)); if (response == null) { throw new NotFoundException("Thing Not Found."); } await context.SendResponse(HttpStatusCode.OK, response); }
public async Task GetThing(IHttpContext context, long referenceId) { Authenticator.VerifyAuth(context); var thing = await Dispatcher.RunOnMainThread(() => ThingsModel.GetThing(referenceId)); if (thing == null) { throw new NotFoundException("Thing not found."); } await context.SendResponse(HttpStatusCode.OK, thing); }
public IActionResult Index() { var records = _recordRepo.GetRecords(); var model = new ThingsModel { Things = records }; _logger.LogInformation("in index now said spiderman"); if (records.Count() > 0) { model.response = "Some stuff"; } else { model.response = "No stuff"; } return(View("Things", model)); }