예제 #1
0
        public HttpResponseMessage PostAmenity(string landlordReference, string submittedPropertyReference,
            Amenity amenity)
        {
            Check.If(landlordReference).IsNotNullOrEmpty();
            Check.If(submittedPropertyReference).IsNotNullOrEmpty();
            Check.If(amenity).IsNotNull();

            var result = _amenityService.CreateAmenity(landlordReference, submittedPropertyReference,
                Mapper.Map<Core.Objects.Amenity>(amenity));

            if (result == null)
            {
                return new HttpResponseMessage {StatusCode = HttpStatusCode.InternalServerError};
            }

            var response = new HttpResponseMessage {StatusCode = HttpStatusCode.Created};

            response.Headers.Location =
                new Uri(Url.Link("GetSubmittedPropertyAmenity",
                    new {landlordReference, submittedPropertyReference, amenityReference = result}));

            return response;
        }
예제 #2
0
        public HttpResponseMessage PutAmenity(string landlordReference, string submittedPropertyReference,
            string amenityReference, Amenity amenity)
        {
            Check.If(landlordReference).IsNotNullOrEmpty();
            Check.If(submittedPropertyReference).IsNotNullOrEmpty();
            Check.If(amenityReference).IsNotNullOrEmpty();
            Check.If(amenity).IsNotNull();

            var result = _amenityService.UpdateAmenity(landlordReference, submittedPropertyReference, amenityReference,
                Mapper.Map<Core.Objects.Amenity>(amenity));

            return result
                ? new HttpResponseMessage {StatusCode = HttpStatusCode.OK}
                : new HttpResponseMessage {StatusCode = HttpStatusCode.InternalServerError};
        }