예제 #1
0
        public object Post(Priority request)
        {
            var priority = PriorityRepository.Add(request);

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

            return new HttpResult(priority)
            {
                StatusCode = HttpStatusCode.Created,
                Headers =
                {
                    { HttpHeaders.Location, Request.AbsoluteUri.CombineWith(priority.Id) }
                }
            };
        }
예제 #2
0
        public object Delete(Priority request)
        {
            var result = PriorityRepository.Delete(request.Id);

            if (!result)
            {
                throw HttpError.Unauthorized("Deleting priority {0} failed".Fmt(request.Id));
            }

            return new HttpResult
            {
                StatusCode = HttpStatusCode.NoContent,
                Headers =
                {
                    { HttpHeaders.Location, Request.AbsoluteUri }
                }
            };
        }
예제 #3
0
        public object Put(Priority request)
        {
            var priority = PriorityRepository.Update(request);

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

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