public async Task <bool> TryPublishCampaign(int campaignId, Distributor distributor) { Campaign campaign = distributor.Campaigns.Where(c => c.Id == campaignId).FirstOrDefault(); if (campaign == null) { throw new Exception("The user does not have a campaign with given ID."); } if (!IsCampaignValid(campaign)) { throw new Exception(String.Format("The campaign '{0}' is not ready to be published. Fill in missing fields.", campaign.CampaignTitle)); } try { string response = await SendGridService.SendCampaignEmail((int)campaignId, _databaseContext); if (response == "done") { return(true); } else { return(false); } } catch (Exception exception) { throw new Exception(exception.Message); } }