コード例 #1
0
        public async Task GetAllThings(IHttpContext context)
        {
            Authenticator.VerifyAuth(context);

            var payload = await Dispatcher.RunOnMainThread(() => ThingsModel.GetThings());

            await context.SendResponse(HttpStatusCode.OK, payload);
        }
コード例 #2
0
        public void GivenColloctionWithSampleDocument()
        {
            _collection = ConnectionHelper.Connection <ThingsModel>("ThingsModel");
            _id         = Guid.NewGuid();
            var t = new ThingsModel {
                _id = _id, IsActive = true
            };

            _collection.InsertOne(t);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }