Beispiel #1
0
 public void Put(Event item)
 {
     if (!repository.Update(item))
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
 }
Beispiel #2
0
        public HttpResponseMessage Post(Event item)
        {
            item.Status = EventStatus.Openning;
            item = repository.Add(item);

            var uri = Url.Link("DefaultApi", new { id = item.Id });
            var response = Request.CreateResponse<Event>(HttpStatusCode.Created, item);
            response.Headers.Location = new Uri(uri);
            return response;
        }
Beispiel #3
0
        public Event Add(Event item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            item.Id = _nextId++;
            events.Add(item);
            return item;
        }
Beispiel #4
0
        public bool Update(Event item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            int index = events.FindIndex(e => e.Id == item.Id);
            if (index == -1)
            {
                return false;
            }

            events.RemoveAt(index);
            events.Add(item);
            return true;
        }