Пример #1
0
 public void Put(EventModel item)
 {
     if (!_repository.Update(item))
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
 }
Пример #2
0
        public EventModel Add(EventModel item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            item.Id = _nextId++;
            _events.Add(item);
            return item;
        }
Пример #3
0
        public HttpResponseMessage Post(EventModel item)
        {
            item.Status = Status.Opening;
            _repository.Add(item);

            var response = Request.CreateResponse<EventModel>(HttpStatusCode.Created, item);
            var url = Url.Link("DefaultApi", new { id = item.Id });
            response.Headers.Location = new Uri(url);
            return response;
        }
Пример #4
0
        public bool Update(EventModel item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            int index = _events.FindIndex(e => e.Id == item.Id);
            if (index == -1) return false;

            _events[index] = item;
            return true;
        }
Пример #5
0
        public HttpResponseMessage Put(int id, EventModel item)
        {
            item.Id = id;
            _repository.Update(item);

            var response = Request.CreateResponse<EventModel>(HttpStatusCode.OK, item);
            var url = Url.Link("DefaultApi", new { id = item.Id });
            response.Headers.Location = new Uri(url);
            return response;
        }