示例#1
0
        public async Task Register(Nag nag, int launches)
        {
            if (nag == null) throw new ArgumentNullException("nag");

            var responseInfo = await Load(nag.Id, nag.Location);
            responseInfo.LaunchCount++;

            if (responseInfo.ShouldNag(launches))
            {
                await ProcessNag(nag, responseInfo);
            }
            else if (responseInfo.IsAwaitingResponse)
            {
                await Persist(responseInfo, nag.Id, nag.Location);
            }
        }
示例#2
0
 public async Task Register(Nag nag, int launches, TimeSpan duration) => await _nagHelper.Register(nag, launches, duration);
示例#3
0
 public async Task Register(Nag nag, int launches) => await _nagHelper.Register(nag, launches);
示例#4
0
 public async Task Register(Nag nag, TimeSpan duration) => await _nagHelper.Register(nag, duration);
示例#5
0
        private async Task<NagResponse> ShowNag(Nag nag)
        {
            var response = NagResponse.NoResponse;
            if (nag.AllowDefer)
            {
                await _dialogService.ShowAsync(nag.Message, nag.Title,
                    new UICommand(nag.AcceptText, command => response = NagResponse.Accept),
                    new UICommand(nag.DeclineText, command => response = NagResponse.Decline),
                    new UICommand(nag.DeferText, command => response = NagResponse.Defer));
            }
            else
            {
                await _dialogService.ShowAsync(nag.Message, nag.Title,
                    new UICommand(nag.AcceptText, command => response = NagResponse.Accept),
                    new UICommand(nag.DeclineText, command => response = NagResponse.Decline));
            }

            return response;
        }
示例#6
0
        private async Task ProcessNag(Nag nag, NagResponseInfo responseInfo)
        {
            var response = await ShowNag(nag);

            if (response == NagResponse.Accept)
            {
                nag.NagAction();
            }
            else if (response == NagResponse.Defer)
            {
                responseInfo.LaunchCount = 0;
                responseInfo.RegistrationTimeStamp = DateTimeOffset.UtcNow;
            }

            responseInfo.LastResponse = response;
            responseInfo.LastNag = DateTimeOffset.UtcNow;

            await Persist(responseInfo, nag.Id, nag.Location);
        }