Esempio n. 1
0
        public async Task <HowToHelpInfo> GetHelpInfo(HowToHelpInfoType type, string token, CancellationToken cancellationToken = new CancellationToken())
        {
            string currentUrl;

            if (!GetCurrentUrl(type, out currentUrl))
            {
                return(null);
            }

            return(await _restService.ExecuteGetAction <HowToHelpInfo>(currentUrl, token, cancellationToken));
        }
Esempio n. 2
0
        private bool GetCurrentUrl(HowToHelpInfoType type, out string resultUrl)
        {
            switch (type)
            {
            case HowToHelpInfoType.BecomeVolunteer:
                resultUrl = BecomeVolunteerUrl;
                break;

            case HowToHelpInfoType.Donate:
                resultUrl = DonateInfoUrl;
                break;

            default:
                resultUrl = string.Empty;
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
        public async Task <bool> UpdateOrCreateHelpInfo(HowToHelpInfo helpInfo, HowToHelpInfoType type, string token, CancellationToken cancelationToken = new CancellationToken())
        {
            string currentUrl;

            if (!GetCurrentUrl(type, out currentUrl))
            {
                return(false);
            }

            Func <string, HowToHelpInfo, string, CancellationToken, Task <bool> > methodToExecute = _restService.ExecutePutAction;

            var oldHelpInfo = await GetHelpInfo(type, token, cancelationToken);

            if (oldHelpInfo == null)
            {
                methodToExecute = _restService.ExecutePostAction;
            }
            else if (oldHelpInfo.Description != null && oldHelpInfo.Description.Equals(helpInfo?.Description, StringComparison.Ordinal))
            {
                return(true);
            }
            return(await methodToExecute(currentUrl, helpInfo, token, cancelationToken));
        }