コード例 #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
ファイル: NagService.cs プロジェクト: manchax/Template10
 public async Task Register(Nag nag, int launches, TimeSpan duration) => await _nagHelper.Register(nag, launches, duration);
コード例 #3
0
ファイル: NagService.cs プロジェクト: manchax/Template10
 public async Task Register(Nag nag, int launches) => await _nagHelper.Register(nag, launches);
コード例 #4
0
ファイル: NagService.cs プロジェクト: manchax/Template10
 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);
        }