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) } } }; }
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 } } }; }
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) } } }; }