예제 #1
0
 public Task <bool> CreateSiteAsync(Site site)
 =>
 _executor.SendRequestAsync(() => Client.PostAsync("create",
                                                   JsonMessage.CreateJsonMessage(
                                                       new { site.Name, site.BusinessId, site.AddressLine1, site.PostCode, site.AddressLine2, site.Email, site.ContactNumber, site.FirstName, site.SecondName }
                                                       )),
                            $"{site.Name} site created succesfully.");
예제 #2
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);
        }
예제 #3
0
        public Task <bool> CreateBusiness(Business business)
        {
            var message = JsonMessage.CreateJsonMessage(
                new { Name = business.Name, TradingName = business.TradingName, WebAddress = business.WebAddress,
                      HeadContactFirstName = business.Contact.FirstName, HeadContactSecondName = business.Contact.SecondName, HeadContactContactNumber = business.Contact.ContactNumber, HeadContactEmail = business.Contact.Email,
                      HeadOfficePostCode   = business.Office.PostCode, HeadOfficeAddressLine1 = business.Office.AddressLine1, HeadOfficeAddressLine2 = business.Office.AddressLine2 });

            return(_httpExecutor.SendRequestAsync(() => Client.PostAsync("create", message), $"{business.Name} account created succesfully"));
        }
예제 #4
0
 public Task <bool> UpdateDetails(Guid id, string name, string tradingName, string webAddress)
 => _httpExecutor.SendRequestAsync(() => Client.PostAsync("update-details", JsonMessage.CreateJsonMessage(new { id, name, tradingName, webAddress })), "Business details updated successfully");
예제 #5
0
 public Task <bool> UpdateOfficeAsync(HeadOffice office, Guid businessId) =>
 _httpExecutor.SendRequestAsync(() => Client.PostAsync("update-office", JsonMessage.CreateJsonMessage(new { BusinessId = businessId, office.PostCode, office.AddressLine1, office.AddressLine2 })), "Business contact updated succesfully");
예제 #6
0
 public Task <bool> UpdateContactAsync(HeadContact contact, Guid businessId) =>
 _httpExecutor.SendRequestAsync(() => Client.PostAsync("update-contact",
                                                       JsonMessage.CreateJsonMessage(
                                                           new { BusinessId = businessId, FirstName = contact.FirstName, SecondName = contact.SecondName, Email = contact.Email, ContactNumber = contact.ContactNumber })),
                                "Business contact updated succesfully.");
예제 #7
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);
            }
        }
예제 #8
0
 public Task <bool> RemoveSiteResourceAsync(Guid resourceId) => _executor.SendRequestAsync(() => Client.PostAsync("remove-site-resource", JsonMessage.CreateJsonMessage(new { resourceId })), "Resource removed succesfully.");
예제 #9
0
 public Task <bool> CreateSiteResource(Guid siteId, string name, string identifier) => _executor.SendRequestAsync(() => Client.PostAsync("create-site-resource", JsonMessage.CreateJsonMessage(new { siteId, name, identifier })), "The resource was added succesfully.");
예제 #10
0
 public Task <bool> UpdateSiteContactAsync(Guid siteId, string firstName, string secondName, string email, string contactNumber) => _executor.SendRequestAsync(() => Client.PostAsync("update-contact", JsonMessage.CreateJsonMessage(new { siteId, firstName, secondName, email, contactNumber })), "Site contact details updated succesfully.");
예제 #11
0
 public Task <bool> UpdateSiteDetailsAsync(Guid siteId, string name, string addressLine1, string addressLine2, string postCode) => _executor.SendRequestAsync(() => Client.PostAsync("update", JsonMessage.CreateJsonMessage(new { siteId, name, addressLine1, addressLine2, postCode })), "Site details updated succesfully.");