public HttpResponseMessage GetAll()
 {
     try
     {
         ItemResponse <RedditPosts> resp = new ItemResponse <RedditPosts>();
         RedditScraperService       svc  = new RedditScraperService();
         resp.Item = svc.GetAll();
         return(Request.CreateResponse(HttpStatusCode.OK, resp));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
 public HttpResponseMessage SavePost(SavePostRequest model)
 {
     if (!ModelState.IsValid)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
     try
     {
         RedditScraperService svc = new RedditScraperService();
         int id = svc.SavePost(model);
         ItemResponse <int> resp = new ItemResponse <int>();
         resp.Item = id;
         return(Request.CreateResponse(HttpStatusCode.OK, resp));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
Example #3
0
 public RedditController(RedditScraperService redditService)
 {
     this.redditService = redditService;
 }