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); } }
public async Task Register(Nag nag, int launches, TimeSpan duration) => await _nagHelper.Register(nag, launches, duration);
public async Task Register(Nag nag, int launches) => await _nagHelper.Register(nag, launches);
public async Task Register(Nag nag, TimeSpan duration) => await _nagHelper.Register(nag, duration);
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; }
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); }