コード例 #1
0
        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());
        }