예제 #1
0
 public TodoView(ToDo t)
     : base("To Dos",
         H1(Text("To Do")),
         P(Text(t.Description)),
         A(ResolveUri.ForTodos(),"ToDo list"))
 {
 }
 public HttpResponse Post(IEnumerable<KeyValuePair<string, string>> content)
 {
     var desc = content.Where(p => p.Key == "desc").Select(p => p.Value).FirstOrDefault();
     if (desc == null)
     {
         return new HttpResponse(HttpStatusCode.BadRequest);
     }
     var td = new ToDo {Description = desc};
     _repo.Add(td);
     return new HttpResponse(HttpStatusCode.SeeOther).WithHeader("Location",ResolveUri.For(td));
 }
예제 #3
0
 public HttpResponseMessage Post(NameValueCollection content)
 {
     var desc = content["desc"];
     if (desc == null)
     {
         return new HttpResponseMessage(HttpStatusCode.BadRequest);
     }
     var td = new ToDo { Description = desc };
     _repo.Add(td);
     var resp = new HttpResponseMessage(HttpStatusCode.SeeOther);
     resp.Headers.Location = new Uri(ResolveUri.For(td));
     return resp;
 }
 public void Add(ToDo td)
 {
     td.Id = _cid;
     _repo.Add(_cid++,td);
 }
 public static string For(ToDo td)
 {
     return string.Format("/todos/{0}", td.Id);
 }
예제 #6
0
 public static string For(ToDo td)
 {
     return string.Format("http://localhost:8080/todos/{0}", td.Id);
 }