Esempio n. 1
0
        public async Task UpdateTemplateStateByDomainAsync(string account, string domain, ResourceState fromState, ResourceState toState, string message = null)
        {
            using (var ctx = new EmailServiceDbEntities(this.connectionString))
            {
                var entities = await ctx.Templates.Where(
                    t => t.EngagementAccount == account &&
                    t.Domain == domain &&
                    t.State == fromState.ToString()).ToListAsync();

                if (entities != null && entities.Count > 0)
                {
                    foreach (var entity in entities)
                    {
                        entity.State        = toState.ToString();
                        entity.StateMessage = message;
                    }

                    await ctx.SaveChangesAsync();
                }
            }
        }
Esempio n. 2
0
        public async Task UpdateTemplateStateByDomainAsync(string account, string domain, ResourceState fromState, ResourceState toState, string message = null, string trackingId = "")
        {
            try
            {
                await this.store.UpdateTemplateStateByDomainAsync(account, domain, fromState, toState, message);

                EmailProviderEventSource.Current.Info(trackingId, this, nameof(this.UpdateTemplateStateByDomainAsync), OperationStates.Succeeded, $"account: {account} domain: {domain} from: {fromState.ToString()} to: {toState.ToString()}");
            }
            catch (Exception ex)
            {
                EmailProviderEventSource.Current.ErrorException(trackingId, this, nameof(this.UpdateTemplateStateByDomainAsync), OperationStates.Failed, $"Failed to update email template state for account: {account}", ex);
                throw new ApplicationException(string.Format($"Failed to update email template state for account: {account}"));
            }
        }