예제 #1
0
        public HttpResponseMessage getAllContactRequests()
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemsResponse <ContactRequest> response = new ItemsResponse <ContactRequest>();

            ContactRequestServices crService = new ContactRequestServices();

            List <ContactRequest> crList = _ContactService.getAllContactRequests();

            response.Items = crList;

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
예제 #2
0
        public HttpResponseMessage resetSpam(int id)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ContactRequestServices crService = new ContactRequestServices();

            bool isSuccessful = _ContactService.resetSpam(id);

            ItemResponse <bool> response = new ItemResponse <bool>();

            response.Item = isSuccessful;

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
예제 #3
0
        public HttpResponseMessage deleteIDContactUs(int id)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            DeleteContactRequest model = new DeleteContactRequest();

            model.id = id;

            ContactRequestServices contactService = new ContactRequestServices();

            bool isSuccessful = _ContactService.deleteContactRequest(model);

            ItemResponse <bool> response = new ItemResponse <bool>();

            response.Item = isSuccessful;

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
예제 #4
0
        //postContactUs: sends AJAX POST input to the Service, and retrieves the ID for output.
        //creates an automated email to the Contact Request's email address.
        public HttpResponseMessage postContactUs(PostContactRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemResponse <int> response = new ItemResponse <int>();

            ContactRequestServices contactService = new ContactRequestServices();

            int tempBlogID = contactService.postContactRequest(model);

            response.Item = tempBlogID;

            EmailRequestModel crModel = new EmailRequestModel();

            crModel.Email = model.Email;
            crModel.Name  = model.Name;

            _EmailService.sendContactRequestEmail(crModel);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }