public override object HandleGET(System.Net.HttpListenerRequest request, ref UtilityClasses.HTTPResponse response) { try { response = ObjectsFactories.HTTPResponseFactory.GetObject().CreateCodeOK(); return(tagsDAO.GetAllTags()); } catch (Exception e) { response = ObjectsFactories.HTTPResponseFactory.GetObject().CreateCodeInternalServerError(); return(response); } }
public override object HandlePOST(System.Net.HttpListenerRequest request, ref UtilityClasses.HTTPResponse response) { try { string json = GetRequestData(request); response = ObjectsFactories.HTTPResponseFactory.GetObject().CreateCodeCreated(); return(usersDAO.SaveUsers(json)); } catch (Exception e) { response = ObjectsFactories.HTTPResponseFactory.GetObject().CreateCodeInternalServerError(); return(response); } }
public override object HandlePOST(System.Net.HttpListenerRequest request, ref UtilityClasses.HTTPResponse response) { try { string json = GetRequestData(request); Poll poll = JsonConvert.DeserializeObject <Poll>(json); response = ObjectsFactories.HTTPResponseFactory.GetObject().CreateCodeCreated(); return(UserFilledAnswersSaver.GetObject().SaveFilledPoll(poll)); } catch (Exception e) { response = ObjectsFactories.HTTPResponseFactory.GetObject().CreateCodeInternalServerError(); return(response); } }
public override object HandleGET(System.Net.HttpListenerRequest request, ref UtilityClasses.HTTPResponse response) { ObjectsFactories.PollsFactory factory = new ObjectsFactories.PollsFactory(); RESTCollectionElementID collectionElementID = GetCollectionElementID(request); try { if (collectionElementID.IsCollection()) { response = ObjectsFactories.HTTPResponseFactory.GetObject().CreateCodeOK(); return(factory.CreateFilledPolls().WithTags().GetPolls()); } else { response = ObjectsFactories.HTTPResponseFactory.GetObject().CreateCodeOK(); return(factory.CreateFilledPoll(collectionElementID.elementNumber).WithAllFilled().GetPoll()); } } catch (Exception e) { response = ObjectsFactories.HTTPResponseFactory.GetObject().CreateCodeInternalServerError(); return(response); } }
public override object HandleDELETE(System.Net.HttpListenerRequest request, ref UtilityClasses.HTTPResponse response) { response = ObjectsFactories.HTTPResponseFactory.GetObject().CreateCodeNotImplemented(); return(response); }