public async Task <IActionResult> Delete(string id) { try { //remove automation Guid automationId = Guid.Parse(id); var existingAutomation = repository.GetOne(automationId); if (existingAutomation == null) { return(NotFound()); } await webhookPublisher.PublishAsync("Automations.AutomationDeleted", existingAutomation.Id.ToString(), existingAutomation.Name).ConfigureAwait(false); bool response = manager.DeleteAutomation(automationId); if (response) { return(Ok()); } else { ModelState.AddModelError("Automation Delete", "An error occured while deleting an automation"); return(BadRequest(ModelState)); } } catch (Exception ex) { return(ex.GetActionResult()); } }
public async Task <IActionResult> Delete(string id, string driveName) { try { //remove automation Guid automationId = Guid.Parse(id); var existingAutomation = repository.GetOne(automationId); if (existingAutomation == null) { return(NotFound()); } await _webhookPublisher.PublishAsync("Automations.AutomationDeleted", existingAutomation.Id.ToString(), existingAutomation.Name).ConfigureAwait(false); _manager.DeleteAutomation(existingAutomation, driveName); return(Ok()); } catch (Exception ex) { return(ex.GetActionResult()); } }