public async Task <IHttpActionResult> PutTopicResultItem(int userId, int topicId, TopicResult item) { TopicResultBL bL = new TopicResultBL(_context); if (!userId.Equals(item.userID) || !topicId.Equals(item.topicID)) { return(BadRequest()); } else if (!bL.TopicResultExists(userId, topicId)) { var isCraeted = await bL.CreateNewTopicResult(item); if (isCraeted == false) { return(InternalServerError()); } return(Created(Request.RequestUri, item)); } var isUpdated = await bL.UpdateTopicResult(item); if (isUpdated == false) { return(InternalServerError()); } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostTopicResult(TopicResult item) { TopicResultBL bL = new TopicResultBL(_context); var isCreated = await bL.CreateNewTopicResult(item); if (isCreated == false) { return(InternalServerError()); } return(Created(String.Format(@"{0}/{1}/{2}", Request.RequestUri, item.userID, item.userID), item)); }
public async Task <IHttpActionResult> GetAllTopicResults() { try { TopicResultBL bL = new TopicResultBL(_context); var results = await bL.GetTopicResults(); return(Ok(results)); } catch (Exception) { return(InternalServerError()); } }
public async Task <IHttpActionResult> DeleteTopicResult(int userId, int topicId) { TopicResultBL bL = new TopicResultBL(_context); if (!bL.TopicResultExists(userId, topicId)) { return(NotFound()); } var result = await bL.DeleteTopicResult(userId, topicId); if (result == null) { return(InternalServerError()); } return(Ok(result)); }
public async Task <IHttpActionResult> GetTopicResults(int userId, int topicId) { try { TopicResultBL bL = new TopicResultBL(_context); var result = await bL.GetTopicResult(userId, topicId); if (result == null) { return(NotFound()); } return(Ok(result)); } catch (Exception) { return(InternalServerError()); } }