コード例 #1
0
        public IHttpActionResult AnotherExampleGet(int id)
        {
            var model = ExampleRepository.GetData();

            return(ExampleReturn("body", "v1"));
            //return BadRequest();
            //return NotFound();
            //return Ok(model);
        }
コード例 #2
0
        public ExampleApiModel AnotherGet(int id)
        {
            var model = ExampleRepository.GetData();

            return(new ExampleApiModel()
            {
                Id = model.Id, Data = model.Data
            });
        }
コード例 #3
0
        // GET api/values/5 - GetData
        public ExampleApiModel Get(int id)
        {
            var model = ExampleRepository.GetData();

            var urlHelper = new UrlHelper(Request);

            //CreateLink(_urlHelper.Link("Example", new {id = 1}), "self");
            //CreateLink(_urlHelper.Link("Example", new {id = 2}), "next");

            return(new ExampleApiModel()
            {
                Id = model.Id, Data = model.Data, Url = urlHelper.Link("Example", new { id })
            });
        }
コード例 #4
0
        // GET api/values/5 - GetData
        public HttpResponseMessage Get(int id)
        {
            var model = ExampleRepository.GetData();

            var urlHelper = new UrlHelper(Request);

            var username = _identityService.GetUser();

            if (username == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, new ExampleApiModel {
                Id = model.Id, Data = username, Url = urlHelper.Link("Example", new { id })
            }));
        }