public HttpResponseMessage PostPhoto(string propertyReference, Photo photo) { Check.If(propertyReference).IsNotNullOrEmpty(); Check.If(photo).IsNotNull(); var result = _photoService.CreatePhoto(propertyReference, Mapper.Map<Core.Objects.Photo>(photo)); if (result == null) { return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError }; } var response = new HttpResponseMessage { StatusCode = HttpStatusCode.Created }; response.Headers.Location = new Uri(Url.Link("GetPhoto", new { propertyReference, photoReference = result })); return response; }
public HttpResponseMessage PutPhoto(string propertyReference, string photoReference, Photo photo) { Check.If(propertyReference).IsNotNullOrEmpty(); Check.If(photoReference).IsNotNullOrEmpty(); Check.If(photo).IsNotNull(); var result = _photoService.UpdatePhoto(propertyReference, photoReference, Mapper.Map<Core.Objects.Photo>(photo)); return result ? new HttpResponseMessage { StatusCode = HttpStatusCode.OK } : new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError }; }