public void Remove(ToDo t) { _todos.Remove(t); }
public void Add(ToDo t) { t.Id = _nextId++; _todos.Add(t); }
HttpResponseMessage PostNewToDo(HttpRequestMessage req) { var body = req.Content.ReadAsString(); dynamic formContent = FormUrlEncodedExtensions.ParseFormUrlEncoded(body); string description = formContent.Description; if (description == null) { return new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest }; } var td = new ToDo(description); _repository.Add(td); var response = new HttpResponseMessage(); response.StatusCode = HttpStatusCode.Created; string uriString = req.RequestUri.AbsoluteUri + "/" + td.Id.ToString(); Uri uri = new Uri(uriString); response.Headers.Location = uri; response.Content = new StringContent(uri.AbsoluteUri, Encoding.UTF8, "text/uri-list"); return response; }