示例#1
0
        public ActionResult Subscribe(Guid userID, Guid repoID)
        {
            _logger.LogInformation("Subscribe now");
            if (_userRepo.Get(userID) == null)
            {
                ModelState.AddModelError("UserError", $"UserID: {userID} not found");
                return(BadRequest(ModelState));
            }

            if (_gitRepo.Get(repoID) == null)
            {
                ModelState.AddModelError("GitRepositoryError", $"GitRepositoryID: {repoID} not found");
                return(BadRequest(ModelState));
            }

            var newSubscription = new Subscription()
            {
                UserId = userID, RepoId = repoID
            };

            _subscriptionRepo.Save(newSubscription);

            return(CreatedAtAction(nameof(subscriptionsByID), new { subID = newSubscription.Id }));
        }