public HttpResponseMessage GetTerm([FromUri] string term) { var glossary = InMemoryGlossaryProvider.Get(); var possibleTerm = glossary.Find(term); if (possibleTerm.HasValue) { return(Request.CreateResponse(HttpStatusCode.OK, possibleTerm.Value)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } }
public HttpResponseMessage UpdateTerm(string name, [FromBody] UpdateTermRequest request) { var glossary = InMemoryGlossaryProvider.Get(); try { var updatedTerm = glossary.Update(name, request); return(Request.CreateResponse(HttpStatusCode.Created, updatedTerm)); } catch (ArgumentNullException e) { logger.Error(e.ToString()); return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public HttpResponseMessage Get([FromBody] RegisterTermRequest request) { var glossary = InMemoryGlossaryProvider.Get(); try { var registeredTerm = glossary.Register(request); return(Request.CreateResponse(HttpStatusCode.Created, registeredTerm)); } catch (ArgumentNullException e) { logger.Error(e.ToString()); return(Request.CreateResponse(HttpStatusCode.BadRequest)); } catch (TermAlreadyRegisteredException e) { logger.Error(e.ToString()); return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public HttpResponseMessage GetCount() { var glossary = InMemoryGlossaryProvider.Get(); return(Request.CreateResponse(HttpStatusCode.OK, glossary.GetCount())); }