public async Task HandleSuccess <TResponse, TAction>(QueryResponse <TResponse> response, TAction action, bool silent = false, string customMessage = "") { // Display message to UI switch (silent) { case true: break; case false: SweetAlertService.FireAsync("Success", string.IsNullOrEmpty(customMessage) ? $"Success: {response.Message}" : $"{customMessage}: {response.Message}"); break; } // If Success URL property is provided, navigate to the given URL if (!action.ContainsProperty("NavigateToOnSuccess")) { return; } var s = action.GetPropertyValue("NavigateToOnSuccess"); if (s is null) { return; } NavigationManager.NavigateTo(s.ToString()); }
public ItemService(HttpClient httpClient, SweetAlertService sweetAlertService) : base(httpClient, sweetAlertService) { var builder = new UriBuilder(httpClient.BaseAddress); builder.Path += "api/Item/"; ControllerUri = builder.Uri; }
public UserInviteService(HttpClient httpClient, SweetAlertService sweetAlertService) : base(httpClient, sweetAlertService) { ConfirmationUriBuilder = new UriBuilder(httpClient.BaseAddress); var builder = new UriBuilder(httpClient.BaseAddress); builder.Path += "api/UserInvite/"; ControllerUri = builder.Uri; }
public MarketItemsService(HttpClient httpClient, IJSRuntime jsRuntime, PlayersService playersService, SweetAlertService swal, BalanceService balanceService) { this.httpClient = httpClient; this.jsRuntime = jsRuntime; this.playersService = playersService; this.swal = swal; this.balanceService = balanceService; }
public UpdateSidebarItemsActionHandler(IConfiguration configuration, ISessionStorageService sessionStorageService, ILocalStorageService localStorageService, SweetAlertService sweetAlertService, NavigationManager navigationManager, EndPointsModel endPoints, IHttpClient httpClient, HttpClient baseHttpClient, IJSRuntime jsRuntime, IMediator mediator, IStore store) : base(configuration, sessionStorageService, localStorageService, sweetAlertService, navigationManager, endPoints, httpClient, baseHttpClient, jsRuntime, mediator, store) { Configuration = configuration; SessionStorageService = sessionStorageService; LocalStorageService = localStorageService; SweetAlertService = sweetAlertService; NavigationManager = navigationManager; EndPoints = endPoints; HttpClient = httpClient; BaseHttpClient = baseHttpClient; JsRuntime = jsRuntime; Mediator = mediator; Store = store; }
public async void DeleteItem(Item itemToDelete) { // todo: sweet alert to confirm that cancellation is desired var result = await SweetAlertService.FireAsync(AlertHelper.ConfirmationWarning(string.Format("Are you sure you want to delete item {0}", itemToDelete.Name))); if (!string.IsNullOrEmpty(result.Value)) // ensures that deletion only occurs after confirmation { await ItemService.DeleteItem(itemToDelete); items = await ItemService.GetItems(); StateHasChanged(); } }
private bool HandleFailure(QueryResponse <ExistenceResponse> request, RegisterAction action) { if (request.HttpStatusCode is HttpStatusCode.Accepted) { return(false); } SweetAlertService.FireAsync($"An error occured while creating your account: {request.Message}", $"", SweetAlertIcon.Error); // If Fail URL property is provided, navigate to the given URL if (!string.IsNullOrEmpty(action.NavigateToOnFailure)) { NavigationManager.NavigateTo(action.NavigateToOnFailure); } return(true); }
protected ActionHandler(IConfiguration configuration, ISessionStorageService sessionStorageService, ILocalStorageService localStorageService, SweetAlertService sweetAlertService, NavigationManager navigationManager, EndPointsModel endPoints, IHttpClient httpClient, HttpClient baseHttpClient, IJSRuntime jsRuntime, IMediator mediator, IStore store) { Configuration = configuration; SessionStorageService = sessionStorageService; LocalStorageService = localStorageService; SweetAlertService = sweetAlertService; NavigationManager = navigationManager; EndPoints = endPoints; HttpClient = httpClient; BaseHttpClient = baseHttpClient; JsRuntime = jsRuntime; Mediator = mediator; Store = store; }
private async Task <SweetAlertResult> SweetPopUptAsync(IJSRuntime jsRuntime, SweetAlertOptions sweetAlert) { try { Swal = new SweetAlertService(jsRuntime); SweetAlertResult result = await Swal.FireAsync(sweetAlert); return(result); } catch (Exception ex) { return(new SweetAlertResult() { Value = $"SweetError: {ex.Message}" }); } }
public async Task <bool> HandleFailure <TAction>(CmdResponse response, TAction action, bool silent = false, string customMessage = "") { if (response.HttpStatusCode is HttpStatusCode.Accepted) { return(false); } // Display message to UI switch (silent) { case true: SweetAlertService.FireAsync("Error", $"There was an error while trying to process your request, please try again later"); break; case false: SweetAlertService.FireAsync("Error", string.IsNullOrEmpty(customMessage) ? $"There was an error while trying to process your request: {response.Message}" : $"{customMessage}: {response.Message}"); break; } // Display error to the console Console.WriteLine($"Error from response: {response.Message}"); // If Fail URL property is provided, navigate to the given URL if (!action.ContainsProperty("NavigateToOnFailure")) { return(true); } var s = action.GetPropertyValue("NavigateToOnFailure"); if (s is null) { return(true); } NavigationManager.NavigateTo(s.ToString()); return(true); }
/// <summary> /// Maps the close dialog for the component. /// </summary> /// <param name="result">Dynamic class result in the Modals/DialogResult format.</param> public async void CloseDialog(dynamic result) { if (result != null && !result.IsCancellation) // if the modal is exited from any fashion other then cancel or save then the result will be null { await ItemService.SaveItem(result.Data); string successMessage; if (result.Data.Id != 0) // The dialog was opened for editing so a different message should be sent. { successMessage = string.Format("Item {0}, sucessfully edited!", result.Data.Name); } else { successMessage = string.Format("Item {0}, sucessfully created!", result.Data.Name); } await SweetAlertService.FireAsync(AlertHelper.ToastSuccess(successMessage)); items = await ItemService.GetItems(); StateHasChanged(); } }
public ServerService(HttpClient httpClient, SweetAlertService sweetAlertService) { Client = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); SweetAlertService = sweetAlertService; }
public BalanceService(HttpClient httpClient, SweetAlertService swal) { this.httpClient = httpClient; this.swal = swal; }
public override async Task <Unit> Handle(RegisterAction action, CancellationToken aCancellationToken) { // Check If Any Given Data Are Already Existing if (await CheckDuplicateRecords(action)) { return(Unit.Value); } // Check If Passwords Are Correct if (!CurrentState.RegisterVm.Password.Equals(CurrentState.RegisterVm.PasswordConfirmation)) { SweetAlertService.FireAsync("Password does not match", $"", SweetAlertIcon.Error); return(Unit.Value); } // Create Guids var identityGuid = Guid.NewGuid(); var credentialGuid = Guid.NewGuid(); // Send Create Identity Request var identityRequest = CurrentState.RegisterVm.Adapt <CreateIdentityRequest>(); identityRequest.Guid = identityGuid; var identity = await IdentityServiceWrapper.CreateIdentity(identityRequest); if (HandleFailure(identity, action)) { return(Unit.Value); } // Send Create Credential Request var credentialRequest = CurrentState.RegisterVm.Adapt <CreateCredentialRequest>(); credentialRequest.Guid = credentialGuid; credentialRequest.IdentityGuid = identityGuid; credentialRequest.RoleEntity = Guid.Parse("fb2ec753-66b2-4259-b65f-1c6402e58209"); var credential = await IdentityServiceWrapper.CreateCredential(credentialRequest); if (HandleFailure(credential, action)) { return(Unit.Value); } // Send Create Phone Contact Request if (!string.IsNullOrEmpty(CurrentState.RegisterVm.PhoneNumber)) { var phoneContact = await IdentityServiceWrapper.CreateContact(new() { CredentialGuid = credentialGuid, ContactType = GenericContactType.Phone, Value = CurrentState.RegisterVm.PhoneNumber }); if (HandleFailure(phoneContact, action)) { return(Unit.Value); } } // Send Create Email Contact Request if (!string.IsNullOrEmpty(CurrentState.RegisterVm.EmailAddress)) { var emailContact = await IdentityServiceWrapper.CreateContact(new() { CredentialGuid = credentialGuid, ContactType = GenericContactType.Phone, Value = CurrentState.RegisterVm.EmailAddress }); if (HandleFailure(emailContact, action)) { return(Unit.Value); } } // If Success URL property is provided, navigate to the given URL await HandleSuccess(credential, action); return(Unit.Value); }