Beispiel #1
0
        public HttpResponseMessage GetBlocks()
        {
            try
            {
                var resultCode = HttpStatusCode.Forbidden;

                var result = _blockRepository.GetAllBlocks();
                resultCode = HttpStatusCode.OK;

                var response = new HttpResponseMessage
                {
                    StatusCode = resultCode,
                    Content    = new StringContent(JsonConvert.SerializeObject(result), Encoding.UTF8,
                                                   "application/json")
                };
                return(response);
            }
            catch (Exception ex)
            {
                var response = new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.Forbidden,
                    Content    = new StringContent(ex.Message, Encoding.UTF8, "application/json")
                };
                return(response);
            }
        }