public void Put(Event item) { if (!repository.Update(item)) { throw new HttpResponseException(HttpStatusCode.NotFound); } }
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; }
public Event Add(Event item) { if (item == null) { throw new ArgumentNullException("item"); } item.Id = _nextId++; events.Add(item); return item; }
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; }