コード例 #1
0
        public void Get_Ok_Test()
        {
            var picture = _context.Pictures.First();
            var result  = _pictureOperations.GetAsync(picture.Id).Result;

            Assert.AreEqual(picture.Id, result.Id);
        }
コード例 #2
0
ファイル: PictureController.cs プロジェクト: navff/mhbb-back
        public async Task <IHttpActionResult> GetAsync(int id)
        {
            var picture = await _pictureOperations.GetAsync(id);

            HttpResponseMessage result = null;

            if (picture == null)
            {
                return(this.Result404("Picture is not found"));
            }

            result = Request.CreateResponse(HttpStatusCode.OK);
            Stream stream = new MemoryStream(picture.Data);

            result.Content = new StreamContent(stream);
            result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");

            return(new ResponseMessageResult(result));
        }