Ejemplo n.º 1
0
            protected override async Task <bool> ExecuteRequestAsync(IAuthenticatedTicket authenticatedTicket, CustomerQueryRqType request)
            {
                // Let's see if we had a previous saved time so we don't re-query the entire QuickBooks every time.
                var previouslySavedFromModified = (await dbContext.QbSettings
                                                   .FirstOrDefaultAsync(m => m.Name == LAST_MODIFIED_CUSTOMER))?.Value;

                request.FromModifiedDate = DATETIMETYPE.ParseOrDefault(previouslySavedFromModified, DATETIMETYPE.MinValue).GetQueryFromModifiedDate();
                return(await base.ExecuteRequestAsync(authenticatedTicket, request));
            }
Ejemplo n.º 2
0
        public static async Task SaveIfNewerAsync(this ApplicationDbContext applicationDbContext, string setting, QbSync.QbXml.Objects.DATETIMETYPE moment)
        {
            if (moment != null)
            {
                var savedSetting = await applicationDbContext.QbSettings.FirstOrDefaultAsync(m => m.Name == setting);

                var existingDateTimeType = DATETIMETYPE.ParseOrDefault(savedSetting?.Value, DATETIMETYPE.MinValue);
                if (moment > existingDateTimeType)
                {
                    if (savedSetting == null)
                    {
                        savedSetting = new QbSetting
                        {
                            Name = setting
                        };
                        applicationDbContext.QbSettings.Add(savedSetting);
                    }

                    savedSetting.Value = moment.ToString();
                    await applicationDbContext.SaveChangesAsync();
                }
            }
        }