public IActionResult ChangeStatus([FromRoute] int topicId, [FromBody] TopicStatus topicStatus) { if (!_topicPermissions.IsAssociatedTo(User.Identity.GetUserIdentity(), topicId)) { return(Forbidden()); } if (!_topicManager.IsValidTopicId(topicId)) { return(NotFound()); } if (!topicStatus.IsStatusValid()) { ModelState.AddModelError("status", "Invalid Status"); return(BadRequest(ModelState)); } if (topicStatus.IsDone() && _topicManager.GetReviews(topicId).Any(r => !r.Status.IsReviewed())) { return(Conflict()); } if (_topicManager.ChangeTopicStatus(User.Identity.GetUserIdentity(), topicId, topicStatus.Status)) { return(Ok()); } return(NotFound()); }
public IActionResult Post([FromBody] TopicFormModel model) { if (!_topicPermissions.IsAllowedToCreate(User.Identity.GetUserIdentity())) { return(Forbidden()); } if (ModelState.IsValid) { if (!TopicStatus.IsStatusValid(model.Status)) { ModelState.AddModelError("Status", "Invalid Topic Status"); } else { var result = _topicManager.AddTopic(User.Identity.GetUserIdentity(), model); if (result.Success) { return(Ok(result)); } } } return(BadRequest(ModelState)); }