Esempio n. 1
0
 public HttpResponseMessage Add(Bar bar)
 {
     var existingBar = _barsFacade.GetBar(bar.Name);
     if (existingBar == null)
     {
         _barsFacade.AddBar(bar.Name);
         var response = Request.CreateResponse(HttpStatusCode.Created);
         response.Content = new StringContent(String.Format("Bar {0} was addied successfully.", bar.Name));
         return response;
     }
     else
     {
         var response = new HttpResponseMessage(HttpStatusCode.NotFound);
         response.Content = new StringContent(String.Format("Bar with name {0} already exists.", bar.Name));
         return response;
     }
 }
Esempio n. 2
0
 public HttpResponseMessage Update(Bar bar)
 {
     var existingBar = _barsFacade.GetBar(bar.Name);
     if (existingBar != null)
     {
         _barsFacade.UpdateBar(bar.Name);
         var response = Request.CreateResponse(HttpStatusCode.OK);
         response.Content = new StringContent(String.Format("Bar {0} was updated successfully.", bar.Name));
         return response;
     }
     else
     {
         var response = new HttpResponseMessage(HttpStatusCode.NotFound);
         response.Content = new StringContent(String.Format("An Bar with name {0} was not found.", bar.Name));
         return response;
     }
 }