コード例 #1
0
        public void Process(OperationResult model)
        {
            Messages.Clear();
            foreach (var errorMessage in model.Errors)
            {
                switch (errorMessage.Code)
                {
                case "Toast.Info":
                    ToastService.ShowInfo(errorMessage.Text);
                    break;

                case "Toast.Success":
                    ToastService.ShowSuccess(errorMessage.Text);
                    break;

                case "Toast.Error":
                    ToastService.ShowError(errorMessage.Text);
                    break;

                case "Toast.Warning":
                    ToastService.ShowWarning(errorMessage.Text);
                    break;

                default:
                    Messages.Add(errorMessage);
                    break;
                }
            }
            Show = true;
            StateHasChanged();
        }
コード例 #2
0
        private async Task PostOrPutAsync <TServico, TDTO>(TServico servico, TDTO dto)
            where TDTO : IDTO <Guid>
            where TServico : IServicoBase <TDTO, Guid>
        {
            HttpResponseMessage httpResponse;

            if (dto.Id == Guid.Empty)
            {
                httpResponse = await servico.PostAsync(dto);
            }
            else
            {
                httpResponse = await servico.PutAsync(dto.Id, dto);
            }

            if (httpResponse.IsSuccessStatusCode)
            {
                ToastService.ShowSuccess("Registro salvo com sucesso");
                NavigationManager.NavigateTo("usuarios");
            }
            else
            {
                ToastService.ShowError("Falha ao tentar salvar o registro!");
            }
        }
コード例 #3
0
        async Task SendEmailAsync()
        {
            if (string.IsNullOrEmpty(ToAddress))
            {
                Message = "Please set a to address and try again ";
                return;
            }
            Email email = new Email();

            email.Subject   = Subject;
            email.ToAddress = ToAddress;
            if (Environment.MachineName == "DESKTOP-UROO8T1" || User.Identity.Name.ToLower() == "*****@*****.**")
            {
                email.ToAddress = "*****@*****.**";
            }
            if (!string.IsNullOrEmpty(EditorContent))
            {
                email.Body = await this.QuillHtml.GetHTML();
            }
            email.Body = $"{email.Body}<br>{EditorContentHtmlSuffix}";
            var response = await EmailService.SendEmailAsync(email);

            if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
            {
                ToastService.ShowSuccess($"Email appears to have been sent correctly to {email.ToAddress}", "SUCCESS");
                await ModalInstance.CloseAsync(ModalResult.Ok <string>(Message));
            }
            else
            {
                ToastService.ShowError($"Email failed to send with the following status code {response.StatusCode}", "ERROR");
            }
        }
コード例 #4
0
        protected virtual async Task <bool> Salvar(EditContext editContext)
        {
            if (!editContext.Validate())
            {
                return(false);
            }

            HttpResponseMessage httpResponse;

            if (!default(TId).Equals(Id))
            {
                httpResponse = await HttpServico.PutAsync(Id, _dto);
            }
            else
            {
                httpResponse = await HttpServico.PostAsync(_dto);
            }

            if (httpResponse.IsSuccessStatusCode)
            {
                ToastService.ShowSuccess("Registro salvo com sucesso");
            }
            else
            {
                ToastService.ShowError("Falha ao tentar salvar o registro!");
                return(false);
            }

            NavigationManager.NavigateTo(AposSalvarRetonarPara);
            return(true);
        }
コード例 #5
0
        private async Task SendGrams()
        {
            //send some grams from giver
            TonContractRunResult result = await TonClient.Contracts.Run(new TonContractRunParams
            {
                Abi          = Static.GiverAbi,
                Address      = Static.GiverAddress,
                FunctionName = "sendGrams",
                Input        = new
                {
                    dest   = AccountAddress,
                    amount = 100000
                }
            }).CatchJsExceptionAsync(ex => ToastService.ShowError(ex.Message));

            if (!result.Transaction.Compute.Success)
            {
                ToastService.ShowError(JsonSerializer.Serialize(result.Transaction));
                return;
            }

            SendingGramsSuccess = result.Transaction.Compute.Success;
            ToastService.ShowSuccess($"GasFees:{result.Fees.GasFee}", "Sending grams is ok");
            ProgressCurrentStep++;
            StateHasChanged();

            var res = await TonClient.Queries.Accounts.Query(new TonQueryParams(new { id = new { eq = AccountAddress } }, "balance"))
                      .CatchJsExceptionAsync(ex => ToastService.ShowError(ex.Message));

            AccountBalance = res[0].Balance !.Value;
        }
コード例 #6
0
        private async Task LoadContract(InputFileChangeEventArgs e)
        {
            FileLoader = true;
            StateHasChanged();

            FileName = e.File.Name;

            await using Stream fileStream = e.File.OpenReadStream();
            await using var memoryStream  = new MemoryStream();
            await fileStream.CopyToAsync(memoryStream);

            JsDataUri = $"data:{e.File.ContentType};base64,{Convert.ToBase64String(memoryStream.ToArray())}";

            try
            {
                ContractPackage = await JsRuntime.InvokeAsync <TonPackage>("getContactPackage", JsDataUri)
                                  .CatchJsExceptionAsync(ex => ToastService.ShowError(ex.Message));
            }
            catch (JSException)
            {
                JsDataUri = null;
                StateHasChanged();
                throw;
            }

            await Task.Delay(1000);

            FileLoader = false;
            ProgressCurrentStep++;
        }
コード例 #7
0
        private async Task Deploy()
        {
            //deploy contract
            TonContractDeployResult deploy = await TonClient.Contracts.Deploy(new TonContractDeployParams
            {
                Package = ContractPackage,
                KeyPair = KeyPair
            }).CatchJsExceptionAsync(ex => ToastService.ShowError(ex.Message));

            if (deploy.AlreadyDeployed)
            {
                ToastService.ShowWarning("Contract already deployed");
                ProgressCurrentStep++;
                DeployContractResult = true;
                return;
            }

            if (deploy.Transaction?.Compute?.Success ?? false)
            {
                ToastService.ShowSuccess($"GasFees:{deploy.Transaction.Compute.GasFees}", "Contract has been deployed");
                ProgressCurrentStep++;
                DeployContractResult = true;
                return;
            }

            ToastService.ShowError(JsonSerializer.Serialize(deploy), "Something went wrong");
        }
コード例 #8
0
        private void ShowError(Exception ex, string message)
        {
#if DEBUG
            Console.WriteLine(ex.ToString());
#endif
            ToastService.ShowError(message);
        }
コード例 #9
0
        protected async Task HandleAddButtonClick()
        {
            if (SelectedListId > 0)
            {
                DisplayLoadingSpinner = true;

                var request = new AddMovieItemRequest
                {
                    TmdbId = Movie.Id,
                    Title  = Movie.Title
                };

                var response = await ListService.AddMovieToListAsync(SelectedListId, request);

                if (response.Success)
                {
                    DisplayLoadingSpinner = false;
                    ToastService.ShowSuccess(response.Message);
                }
                else
                {
                    DisplayLoadingSpinner = false;
                    ToastService.ShowError(response.Message);
                }
            }
        }
コード例 #10
0
ファイル: UserCreateBase.cs プロジェクト: niqqq25/Sawmill.NET
        protected async Task HandleUserCreate()
        {
            if (!await RoleManager.RoleExistsAsync(User.Role))
            {
                ToastService.ShowError("Tokios pareigos neegzistuoja");
                return;
            }

            var user = new ApplicationUser {
                UserName = User.Email, Email = User.Email, FirstName = User.FirstName, LastName = User.LastName
            };
            var userCreateResult = await UserManager.CreateAsync(user, User.Password);

            if (userCreateResult.Succeeded)
            {
                await UserManager.AddToRoleAsync(user, User.Role);

                ToastService.ShowSuccess($"Darbuotojo paskyra yra sėkmingai sukurta");
                NavigationManager.NavigateTo("/users");
            }
            else
            {
                ToastService.ShowError("Nepavyko sukurti darbuotojo paskyros");
            }
        }
コード例 #11
0
        protected void DeleteCategory(int id)
        {
            Category cat = _categories.FirstOrDefault(p => p.Id == id);

            if (cat.Products == null || cat.Products.Count == 0)
            {
                try
                {
                    Repository.Delete(cat);
                    _categories.Remove(cat);
                    _sortedCategories.Remove(cat);
                    Telemetry.TrackEvent("CategoryDelete");
                }
                catch (Exception ex)
                {
                    Telemetry.TrackException(ex);
                    ToastService.ShowError("Kon categorie niet verwijderen.");
                }
            }
            else
            {
                Telemetry.TrackEvent("CategoryDeleteFail");
                ToastService.ShowError("Categorie heeft producten.");
            }
        }
コード例 #12
0
        private async Task ApplyToVideoJob()
        {
            if (this.VideoJobApplicationEditForm.EditContext.Validate())
            {
                try
                {
                    IsLoading = true;
                    await this.VideoJobApplicationClientService
                    .AddVideoJobApplicationAsync(this.CreateVideoJobApplicationModel);

                    CleanVideoJobApplication();
                    await LoadJobs();

                    ToastService.ShowSuccess(Localizer[VideoJobApplicationSentTextKey]);
                }
                catch (Exception ex)
                {
                    CleanVideoJobApplication();
                    ToastService.ShowError(ex.Message);
                }
                finally
                {
                    IsLoading = false;
                }
            }
        }
コード例 #13
0
 protected void Submit()
 {
     if (_editContext.Validate())
     {
         _product.ProductNumber = Regex.Replace(_product.ProductNumber, @"\s+", "");
         if (!Repository.ProductDuplicateExists(_product.Id, _product.ProductNumber))
         {
             try
             {
                 Repository.Save(_product);
                 _product.Category.Products.Add(_product);
                 ToastService.ShowSuccess("Product: " + _product.Description + " werd toegevoegd in categorie: " + _product.Category.CategoryName);
                 Telemetry.TrackEvent("NonUniqueProductNumber");
                 NavigationManager.NavigateTo("/beheer");
             }
             catch (Exception ex)
             {
                 Telemetry.TrackException(ex);
                 ToastService.ShowError("Kon product niet opslaan.");
             }
         }
         else
         {
             Telemetry.TrackEvent("NonUniqueProductNumber");
             ToastService.ShowError("Product met identiek productnummer bestaat al.");
         }
     }
 }
コード例 #14
0
        private async Task UpdateMnemonicWordsFromRandom()
        {
            MnemonicWords = "updating...";
            MnemonicWords = await TonClient.Crypto.MnemonicWordsFromRandom(new TonMnemonicFromRandomParams())
                            .CatchJsExceptionAsync(ex => ToastService.ShowError(ex.Message));

            StateHasChanged();
        }
コード例 #15
0
        private void SelecionaHorarioReagendamento(ChangeEventArgs args)
        {
            if (!TimeSpan.TryParse(args.Value.ToString(), out TimeSpan horarioDaConsulta))
            {
                ToastService.ShowError("O horário selecionado é inválido");
                return;
            }

            _horarioDaConsulta = horarioDaConsulta;
        }
コード例 #16
0
        protected void RemoveGene()
        {
            if (FitnessOptions.Genetic.Contains(Config.FitnessTypeName) && Config.Genes.Length == 2)
            {
                ToastService.ShowError("Minimum of 2 genes for Genetic algorithms.");
                return;
            }

            Config.Genes = Config.Genes.Except(new[] { Config.Genes.Last() }).ToArray();
        }
コード例 #17
0
 private void DeleteTemplate(MailTemplate template)
 {
     try
     {
         ItemRepository.Delete(template);
         _templates.Remove(template);
         _selectedTemplate = null;
         ToastService.ShowSuccess("Template verwijderd.");
     } catch (Exception ex)
     {
         ToastService.ShowError("Kon template niet verwijderen.");
     }
 }
コード例 #18
0
        protected async Task HandleFormSubmit()
        {
            var result = await ManufacturingOrderService.CreateOrder(Order);

            if (result != null)
            {
                ToastService.ShowSuccess($"Gamybos užsakymas '{Product.Name}' yra sėkmingai sukurtas");
                NavigationManager.NavigateTo("/morders");
            }
            else
            {
                ToastService.ShowError("Nepavyko sukurti gamybos užsakymo");
            }
        }
コード例 #19
0
ファイル: Booking.razor.cs プロジェクト: jakarlse88/p8
        /// <summary>
        /// Handle form submission.
        /// </summary>
        /// <returns></returns>
        private async Task HandleSubmit()
        {
            var requestUrl =
                Env.IsDevelopment()
                    ? "https://localhost:5009/client-gw/appointment"
                    : "https://localhost:8088/client-gw/appointment";

            Status = APIOperationStatus.POST_Pending;
            StateHasChanged();

            if (!PatientInApprovedList())
            {
                ToastService.ShowError(
                    "Patient not found. Please ensure that the personal details entered are correct and try again.");
                Status = APIOperationStatus.GET_Success;
                StateHasChanged();
                return;
            }

            if (AppointmentAlreadySubmitted())
            {
                ToastService.ShowError(
                    "There selected consultant already has an appointment scheduled at the selected time.");
                Status = APIOperationStatus.GET_Success;
                StateHasChanged();
                return;
            }

            try
            {
                var dto = CreateDTO();

                var result = await ApiRequestService.HandlePostRequest(requestUrl, dto);

                Status = APIOperationStatus.POST_Success;

                var consultant = ViewModel.ConsultantList.FirstOrDefault(c => c.Id == result.ConsultantId);
                var timeSlot   = ViewModel.TimeSlotList.FirstOrDefault(ts => ts.Id == result.TimeSlotId);

                ToastService.ShowSuccess(
                    $"Appointment with Dr. {consultant?.FirstName} {consultant?.LastName} ({consultant?.Specialty}) on {result.Date:dd/MM/yyyy} from {timeSlot?.StartTime:hh:mm} to {timeSlot?.EndTime:hh:mm} successfully scheduled.");

                NavigationManager.NavigateTo("/");
            }
            catch (Exception e)
            {
                ToastService.ShowError(
                    "There was an error submitting your request. Please ensure that the entered is correct data and retry.");
            }
        }
コード例 #20
0
        protected async Task HandleFormSubmit()
        {
            var result = await CustomerOrderService.CreateOrder(Order);

            if (result != null)
            {
                ToastService.ShowSuccess($"Užsakymas '{result.Id}' yra sėkmingai sukurtas");
                NavigationManager.NavigateTo("/orders");
            }
            else
            {
                ToastService.ShowError("Nepavyko sukurti užsakymo");
            }
        }
コード例 #21
0
        protected async Task HandleFormSubmit()
        {
            var result = await ProductService.EditProduct(Id, Product);

            if (result != null)
            {
                ToastService.ShowSuccess($"Produktas '{Product.Name}' yra sėkmnigai atnaujintas");
                NavigationManager.NavigateTo("/products");
            }
            else
            {
                ToastService.ShowError("Nepavyko atnaujinti produkto");
            }
        }
コード例 #22
0
        protected async Task HandleFormSubmit()
        {
            var result = await ResourceService.EditResource(Id, Resource);

            if (result != null)
            {
                ToastService.ShowSuccess($"Resursas '{Resource.Name}' yra sėkmnigai atnaujintas");
                NavigationManager.NavigateTo("/resources");
            }
            else
            {
                ToastService.ShowError("Nepavyko atnaujinti resurso");
            }
        }
コード例 #23
0
        protected async Task OnRemoveHousehold()
        {
            var removeSuccessful = await HouseholdDataService.DeleteHousehold(Household.HouseholdId);

            if (removeSuccessful)
            {
                NavigationManager.NavigateTo("/");
                ToastService.ShowInfo($"Successfully removed {Household.Name}");
            }
            else
            {
                ToastService.ShowError($"Could not remove {Household.Name}", "Delete failed");
            }
        }
コード例 #24
0
        protected async Task HandleFormSubmit()
        {
            var result = await ResourceService.CreateResource(Resource);

            if (result != null)
            {
                ToastService.ShowSuccess($"Resursas '{Resource.Name}' yra sėkmingai sukurtas");
                NavigationManager.NavigateTo("/resources");
            }
            else
            {
                ToastService.ShowError("Nepavyko sukurti resurso");
            }
        }
コード例 #25
0
        protected async Task HandleFormSubmit()
        {
            var result = await ProcessService.EditProcess(Id, Process);

            if (result != null)
            {
                ToastService.ShowSuccess($"Gamybos procesas '{Process.Name}' yra sėkmnigai atnaujintas");
                NavigationManager.NavigateTo("/processes");
            }
            else
            {
                ToastService.ShowError("Nepavyko atnaujinti gamybos proceso");
            }
        }
コード例 #26
0
        protected async Task HandleFormSubmit()
        {
            var result = await CustomerOrderService.EditOrder(Id, OrderUpdate);

            if (result != null)
            {
                ToastService.ShowSuccess($"Gamybos užsakyms '{Order.Id}' yra sėkmnigai atnaujintas");
                NavigationManager.NavigateTo("/orders");
            }
            else
            {
                ToastService.ShowError("Nepavyko atnaujinti gamybos užsakymo");
            }
        }
コード例 #27
0
        protected async Task HandleFormSubmit()
        {
            var result = await ProductService.CreateProduct(Product);

            if (result != null)
            {
                ToastService.ShowSuccess($"Produktas '{Product.Name}' yra sėkmingai sukurtas");
                NavigationManager.NavigateTo("/products");
            }
            else
            {
                ToastService.ShowError("Nepavyko sukurti produkto");
            }
        }
コード例 #28
0
ファイル: FridgeDetailBase.cs プロジェクト: huserben/Frinfo
        protected async void OnRemoveFridge()
        {
            var wasRemoveSuccessful = await FridgeDataService.DeleteFridge(Fridge.HouseholdId, Fridge.FridgeId);

            if (wasRemoveSuccessful)
            {
                NavigationManager.NavigateTo($"household/{Fridge.HouseholdId}");
                ToastService.ShowInfo($"Removed {Fridge.Name}");
            }
            else
            {
                ToastService.ShowError($"Failed to remove {Fridge.Name}", "Delete Failed");
            }
        }
コード例 #29
0
        protected void Submit()
        {
            Product  product  = null;
            Supplier supplier = null;
            string   serialnr = null;

            if (_productNumber != null)
            {
                product = Repository.GetByProductNr(_productNumber);
            }

            if (_selectedSupplier != null)
            {
                supplier = _suppliers.FirstOrDefault(p => p.Id == _selectedSupplier);
            }

            if (_serialNumber != null)
            {
                serialnr           = Regex.Replace(_serialNumber, @"\s+", "");
                _item.SerialNumber = serialnr;
            }

            _item.Product  = product;
            _item.Supplier = supplier;

            if (_editContext.Validate())
            {
                if (!Repository.ItemDuplicateExists(_item.Id, _item.SerialNumber, _item.Product.Id))
                {
                    Repository.Save(_item);
                    Telemetry.TrackEvent("AddItem");
                    ToastService.ShowSuccess("Item toegevoegd");
                    product.AddItem(_item);
                    StateHasChanged();
                    _serialNumber = null;
                    _item         = new Item()
                    {
                        Product  = product,
                        Supplier = supplier
                    };
                    _editContext = new EditContext(_item);
                }
                else
                {
                    Telemetry.TrackEvent("AddItemFail");
                    ToastService.ShowError("Duplicate item bestaat al in de databank.");
                }
            }
        }
コード例 #30
0
ファイル: FridgeDetailBase.cs プロジェクト: huserben/Frinfo
        protected async Task DeleteFridgeItem(FridgeItem fridgeItem)
        {
            var wasRemoveSuccessful = await FridgeDataService.DeleteFridgeItem(Fridge.HouseholdId, Fridge.FridgeId, fridgeItem.FridgeItemId);

            if (wasRemoveSuccessful)
            {
                FridgeItems.Remove(fridgeItem);
                StateHasChanged();
                ToastService.ShowInfo($"Successfully removed {fridgeItem.Name}");
            }
            else
            {
                ToastService.ShowError($"Could not remove {fridgeItem.Name}", "Delete Failed");
            }
        }