public Question(int ID, string question, Category category, string reporterEmail, DateTime reportedTime) { this.ID = ID; this.question = question; this.category = category; this.reporterEmail = reporterEmail; this.reportedTime = reportedTime; }
// POST /api/Category public HttpResponseMessage Post(Category category) { if(!ModelState.IsValid) return new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Failed to insert data. The model state is invalid: " + ModelState.ToString()) }; int categoryID = new DACategory().insert(category); if (categoryID == -1) return new HttpResponseMessage() { StatusCode = HttpStatusCode.ExpectationFailed, Content = new StringContent("Failed to insert data.") }; var json = new JavaScriptSerializer(); string data = json.Serialize(categoryID); return new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(data, Encoding.UTF8, "application/json") }; }