Ejemplo n.º 1
0
        private async Task RefreshVouchers()
        {
            var updatedVouchers = await _voucherService.RefreshVouchers(this.Event.Vouchers.Select(x => x.Id));

            if (_shouldAutomaticRefreshVouchers && updatedVouchers != null)
            {
                try
                {
                    var enumerator = this.Event.Vouchers.GetEnumerator();
                    enumerator.MoveNext();
                    do
                    {
                        var oldVoucher = enumerator.Current;
                        var newVoucher = updatedVouchers.First(x => x.Id == oldVoucher.Id);
                        oldVoucher.CurrentStatus = newVoucher.CurrentStatus;
                        oldVoucher.EntryDate     = newVoucher.EntryDate;
                        oldVoucher.Gate          = newVoucher.Gate;

                        /*Force recheck of voucher status based on the configuration dates*/
                        oldVoucher.CheckVoucherStatus();

                        await _voucherRepository.UpdateAsync(oldVoucher);
                    } while (enumerator.MoveNext());
                }
                catch (Exception)
                {
                }
            }
            RaisePropertyChanged("Event");
        }