コード例 #1
0
        public object Post(Status request)
        {
            var status = StatusRepository.Add(request);

            if (status == null)
            {
                throw HttpError.Unauthorized("Creating a new status failed");
            }

            return new HttpResult(status)
            {
                StatusCode = HttpStatusCode.Created,
                Headers =
                {
                    { HttpHeaders.Location, Request.AbsoluteUri.CombineWith(status.Id) }
                }
            };
        }
コード例 #2
0
        public object Delete(Status request)
        {
            var result = StatusRepository.Delete(request.Id);

            if (!result)
            {
                throw HttpError.Unauthorized("Deleting status {0} failed");
            }

            return new HttpResult
            {
                StatusCode = HttpStatusCode.NoContent,
                Headers =
                {
                    { HttpHeaders.Location, Request.AbsoluteUri }
                }
            };
        }
コード例 #3
0
        public object Put(Status request)
        {
            var status = StatusRepository.Update(request);

            if (status == null)
            {
                throw HttpError.Unauthorized("Updating status {0} failed".Fmt(request.Id));
            }

            return new HttpResult(status)
            {
                StatusCode = HttpStatusCode.NoContent,
                Headers =
                {
                    { HttpHeaders.Location, Request.AbsoluteUri.CombineWith(status.Id) }
                }
            };
        }