コード例 #1
0
        public HttpResponseMessage Put(string eventReference, Event anEvent)
        {
            Check.If(eventReference).IsNotNullOrEmpty();
            Check.If(anEvent).IsNotNull();

            var result = _eventService.UpdateEvent(eventReference, Mapper.Map<Core.Objects.Event>(anEvent));

            return result
                ? new HttpResponseMessage { StatusCode = HttpStatusCode.OK }
                : new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError };
        }
コード例 #2
0
        public HttpResponseMessage Post(Event anEvent)
        {
            Check.If(anEvent).IsNotNull();
            Check.If(anEvent.ApplicationReference).IsNotNullOrEmpty();

            var result = _eventService.CreateEvent(Mapper.Map<Core.Objects.Event>(anEvent));

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

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

            response.Headers.Location = new Uri(Url.Link("GetEvent", new { eventReference = result }));

            return response;
        }