private ChildBug GetBugWithId(Guid bugId) { var bug = Bugs.SingleOrDefault(x => x.Id == bugId); if (bug == null) { throw new EntityDoesNotExistsInScope(bugId, nameof(ChildBug), nameof(Task), Id); } return(bug); }
public static async Task <(bool success, string message)> UpdateBuggedAsync(string CardName, string Player, int MatchID, bool isFixed) { if (string.IsNullOrEmpty(CardName)) { return(false, "You need to specify the card name."); } try { CheckForNewList(); var bug = Bugs.SingleOrDefault(n => n.CardName == CardName); if (bug != null) { var repo = await GetRepositoryAsync(); var num = int.Parse(bug.Url.Split('/').Last()); var issue = await GithubClient.Issue.Get(repo.Id, num); var verification = await GetVerificationForBugAsync(issue.Number); if (verification != null && verification.Equals(await GetCurrentBuildAsync())) { return(true, "Thanks, but our information about this bug is already up to date."); } var md_link = $"in match [{MatchID}](https://logs.pennydreadfulmagic.com/match/{MatchID}/)"; if (MatchID == -1) { md_link = "on discord"; } string stillBuggedText; if (isFixed) { stillBuggedText = $"Fixed according to `{Player}` {md_link}."; } else { stillBuggedText = $"Still bugged according to `{Player}` {md_link}."; } await GithubClient.Issue.Comment.Create(repo.Id, issue.Number, stillBuggedText); if (!isFixed) { var currentCol = await GetLatestColumnAsync(); if (verification == null) { await GithubClient.Repository.Project.Card.Create(currentCol.Id, new NewProjectCard(issue.Id, ProjectCardContentType.Issue)); } else { var card = await GetCardForBugAsync(issue.Number); await GithubClient.Repository.Project.Card.Move(card.Id, new ProjectCardMove(ProjectCardPosition.Top, currentCol.Id, null)); } Verifications[issue.Number] = await GetCurrentBuildAsync(); return(true, "Thanks, I've updated my records!"); } else { return(true, "Thanks, Our team will review this match shortly"); } } return(false, "I couldn't find a bug for that card."); } catch (Exception c) { var msg = $"Error updating Modo-bugs:\nCardName={CardName}\n{c}"; await DiscordService.SendToTestAsync(msg); Console.WriteLine(msg); } return(false, "Sorry, I encountered an error. Please PM me the details."); }