Exemple #1
0
        public async Task <bool> DeleteAccount(Guid accountId, Guid businessId)
        {
            HttpResponseMessage response = null;

            try
            {
                response = await _client.IdentityClient.PostAsync("admin/remove", JsonMessage.CreateJsonMessage(new { BusinessId = businessId, Id = accountId }));;
            }
            catch (HttpRequestException)
            {
                _toastService.ShowError(ServiceError.Standard.Reason);
                return(false);
            }

            if (response.IsSuccessStatusCode)
            {
                _toastService.ShowSuccess($"admin removed successfully.");
                return(true);
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                var error = await ServiceError.Deserialize(response);

                _toastService.ShowError(error.Reason);
                return(false);
            }

            return(false);
        }
Exemple #2
0
        public async Task <ServiceError> CreateAdmin(string email)
        {
            CheckHeaders();
            var message = new StringContent(JsonConvert.SerializeObject(new { Email = email }), Encoding.UTF8, "application/json");
            HttpResponseMessage response;

            try
            {
                response = await Client.PostAsync("admin/create", message);
            }
            catch (HttpRequestException)
            {
                return(ServiceError.Standard);
            }

            if (response.IsSuccessStatusCode)
            {
                return(null);
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                return(await ServiceError.Deserialize(response));
            }
            return(ServiceError.Standard);
        }
Exemple #3
0
        public async Task SubmitAsync()
        {
            HttpResponseMessage response = null;

            try
            {
                response = await _client.IdentityClient.PostAsync("admin/create-business-admin", JsonMessage.CreateJsonMessage(new { BusinessId = Id, Email }));
            }
            catch (HttpRequestException)
            {
                _toastService.ShowError(ServiceError.Standard.Reason);
                return;
            }

            if (response.IsSuccessStatusCode)
            {
                _modalService.Close(ModalResult.Cancel());
                _toastService.ShowSuccess($"Email sent to user {Email} to confirm their account");
                Email = string.Empty;
                Id    = Guid.Empty;
                return;
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                var error = await ServiceError.Deserialize(response);

                _toastService.ShowError(error.Reason);
            }
        }
Exemple #4
0
        public async Task <ServiceError> CompleteAdmin(string email, Guid code, string password, string passwordMatch)
        {
            var message = new StringContent(JsonConvert.SerializeObject(new { Email = email, Code = code, Password = password, PasswordMatch = passwordMatch }), Encoding.UTF8, "application/json");
            HttpResponseMessage response;

            try
            {
                response = await Client.PostAsync("admin/complete", message);
            }
            catch (HttpRequestException)
            {
                return(ServiceError.Standard);
            }
            if (response.IsSuccessStatusCode)
            {
                return(null);
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                return(await ServiceError.Deserialize(response));
            }

            return(ServiceError.Standard);
        }