Esempio n. 1
0
        public async static Task <RemovePermissionResponse> Remove(GetAddesssApi api, RemovePermissionRequest request, string path, AdminKey adminKey)
        {
            if (api == null)
            {
                throw new ArgumentNullException(nameof(api));
            }
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            api.SetAuthorizationKey(adminKey);

            var fullPath = path + $"{request.EmailAddress}/";

            var response = await api.Delete(fullPath);

            var body = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                var message = MessageResponse.GetMessageResponse(body);

                return(new RemovePermissionResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, message.Message));
            }

            return(new RemovePermissionResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body));
        }
Esempio n. 2
0
        public async static Task <AddPermissionResponse> Add(GetAddesssApi api, AddPermissionRequest request, string path, AdminKey adminKey)
        {
            if (api == null)
            {
                throw new ArgumentNullException(nameof(api));
            }
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            api.SetAuthorizationKey(adminKey);

            var response = await api.Post(path, request);

            var body = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                var message = MessageResponse.GetMessageResponse(body);

                return(new AddPermissionResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, message.Message));
            }

            return(new AddPermissionResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body));
        }
        public string ProcessInput(string subText)
        {
            if (string.IsNullOrEmpty(subText))
            {
                return(MessageResponse.GetMessageResponse(Enum.MessageResponseType.ExceptionNoDataInputFound));
            }

            var       position = "";
            const int diff     = 32;

            try
            {
                for (var i = 0; i < MainText.Length; i++)
                {
                    bool find = false;

                    if (subText[0] == MainText[i] || subText[0] + diff == MainText[i] || subText[0] - diff == MainText[i])
                    {
                        find = true;
                        for (var j = 1; j < subText.Length; j++)
                        {
                            if (subText[j] != MainText[i + j] && MainText[i + j] != subText[j] + diff && MainText[i + j] != subText[j] - diff)
                            {
                                find = false;
                                break;
                            }
                        }

                        if (find)
                        {
                            var pos = i + 1;
                            if (position.Length == 0)
                            {
                                position += pos.ToString(CultureInfo.InvariantCulture);
                            }
                            else
                            {
                                position += ", " + pos.ToString(CultureInfo.InvariantCulture);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("{0} | {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, ex));
                return(MessageResponse.GetMessageResponse(Enum.MessageResponseType.ExceptionError));
            }
            if (string.IsNullOrEmpty(position))
            {
                position = "<no matches>";
            }

            return(position);
        }