예제 #1
0
        private IHttpContext PutHandler(IHttpContext context)
        {
            context.Response.ContentType = ContentType.JSON;

            String json;

            try
            {
                String body         = context.Request.Payload;
                var    genre        = _jsonService.Read <Genre>(body);
                var    updatedGenre = _dataService.UpdateGenre(genre);
                json = _jsonService.Write(updatedGenre);
            }
            catch (Exception e)
            {
                context.Response.StatusCode = HttpStatusCode.InternalServerError;
                json = _jsonService.Write(new ErrorMessage(e.Message));
            }

            context.Response.SendResponse(Encoding.ASCII.GetBytes(json));
            return(context);
        }