Exemplo n.º 1
0
        public async Task ProcessDeleteWebhook(CreateOrDeleteWebhook createOrDeleteWebhook)
        {
            if (createOrDeleteWebhook.ref_type != "branch")
            {
                return;
            }

            var repo = await _databaseContext.Repositories
                       .Where(r => r.Id == createOrDeleteWebhook.repository.id)
                       .Select(r => r)
                       .Include(r => r.Project)
                       .SingleOrDefaultAsync();

            if (repo?.Project == null)
            {
                // TODO logging
                return;
            }

            var ticket = await _databaseContext.Tickets
                         .Where(t => t.ProjectId == repo.ProjectId && t.Name == createOrDeleteWebhook.ref_)
                         .Select(t => t)
                         .SingleOrDefaultAsync();

            if (ticket == null)
            {
                // TODO logging
                return;
            }

            await _ticketService.DeleteTicket(ticket);

            await _databaseContext.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Delete([FromBody] CreateOrDeleteWebhook createOrDeleteWebhook)
        {
            await _webhookService.ProcessDeleteWebhook(createOrDeleteWebhook);

            return(Ok());
        }