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.");
         }
     }
 }
        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;
                }
            }
        }
        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");
        }
示例#4
0
        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");
            }
        }
        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");
            }
        }
示例#6
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);
        }
        protected async Task HandleValidSubmit()
        {
            Saved = false;
            var savedUser = new User();

            savedUser = await UserDataService.AddUser(User);

            if (savedUser != null && UserId == 0)
            {
                StatusClass = "alert-success";
                Message     = "New User Added Successfuly";
                Saved       = true;
            }
            else if (savedUser != null && UserId != 0)
            {
                StatusClass = "alert-success";
                Message     = "User Updated Successfuly";
                Saved       = true;
            }
            else
            {
                StatusClass = "alert-danger";
                Message     = "somthing went wrong adding the new user .please try again";
                Saved       = false;
            }
            ShowDialog = false;
            await CloseEventCallback.InvokeAsync(true);

            StateHasChanged();
            ToastService.ShowSuccess(Message, "Confirm");
        }
示例#8
0
        protected async Task HandleValidSubmit()
        {
            Employee.CountryId     = int.Parse(CountryId);
            Employee.JobCategoryId = int.Parse(JobCategoryId);
            if (ValidateTasks() == false)
            {
                Saved       = false;
                StatusClass = "alert-danger";
                TaskMessage = "There is a validation problem with the tasks please check and try again.";
                return;
            }
            if (Employee.EmployeeId == 0)             //new
            {
                var addedEmployee = await EmployeeDataService.AddEmployee(Employee);

                if (addedEmployee != null)
                {
                    ToastService.ShowSuccess("New employee added successfully.", "Success");
                    Saved = true;
                }
                else
                {
                    StatusClass = "alert-danger";
                    Message     = "Something went wrong adding the new employee. Please try again.";
                    Saved       = false;
                }
            }
            else
            {
                await EmployeeDataService.UpdateEmployee(Employee);

                ToastService.ShowSuccess("Employee updated successfully.", "Success");
                Saved = true;
            }
        }
        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);
                }
            }
        }
        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!");
            }
        }
        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();
        }
示例#12
0
        public async Task PublishProject()
        {
            project.IsPublished = true;
            await ProjectData.UpdatePublishStatus(project);

            ToastService.ShowSuccess("Project Published Successfully", "-");
        }
        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;
        }
示例#14
0
        private async Task Update()
        {
            await CustomerRepo.UpdateCustomer(_customer);

            ToastService.ShowSuccess($"Action successful." +
                                     $"Customer \"{_customer.Name}\" successfully updated.");
            //_customer = new Customer();
        }
示例#15
0
 protected void ValidSubmit()
 {
     Json = JsonSerializer.Serialize(Config, new JsonSerializerOptions {
         WriteIndented = true, IgnoreNullValues = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase
     });
     StoreConfig(Config);
     ToastService.ShowSuccess("Config was stored.");
 }
示例#16
0
        private async Task Update()
        {
            await EmployeeRepo.UpdateEmployee(_employee);

            ToastService.ShowSuccess($"Action successful." +
                                     $"Employee \"{_employee.Name}\" successfully updated.");
            _employee = new Employee();
        }
示例#17
0
        protected async Task HandleValidSubmit()
        {
            await EmployeeDataService.AddEmployee(Employee);

            await ModalInstance.CloseAsync(ModalResult.Ok(true));

            ToastService.ShowSuccess($"{Employee.FullName} Added successfully.", "Success");
        }
示例#18
0
        protected async Task HandleValidSubmit()
        {
            await TaskDataService.AddTask(Task);

            await ModalInstance.CloseAsync(ModalResult.Ok(true));

            ToastService.ShowSuccess($"{Task.Title} Added successfully.", "Success");
        }
示例#19
0
        private async Task UpdatePersonAsync()
        {
            await PersonService.UpdatePersonAsync(PersonToUpdate);

            ToastService.ShowSuccess($"{ Person.Name } has been updated successfully.", "Person Updated");

            IsEditing = false;
            StateChanged?.Invoke();
        }
示例#20
0
        protected async Task ConfirmDelete_Click(bool deleteConfirmed)
        {
            if (deleteConfirmed)
            {
                await InvoiceService.DeleteInvoice(Invoice.InvoiceNumber);

                ToastService.ShowSuccess(Invoice.InvoiceNumber + " was removed successfully");
                NavigationManager.NavigateTo("/Invoices");
            }
        }
示例#21
0
        public async void DeleteUser(long id)
        {
            if (!await JSRuntime.InvokeAsync <bool>("confirm", "Are you sure you want to delete this user"))
            {
                return;
            }
            await UserDataService.DeleteUser(id);

            Users = (await UserDataService.GetAllUsers()).ToList();
            StateHasChanged();
            ToastService.ShowSuccess("User Deleted Successfuly", "Confirm");
        }
示例#22
0
        private async Task OnAddCategory()
        {
            var categoryForm = ModalService.Show <CategoryForm>("افزودن دسته");

            var result = await categoryForm.Result;

            if (!result.Cancelled)
            {
                ToastService.ShowSuccess("افزودن دسته با موفقیت انجام شد");

                await LoadTableData();
            }
        }
 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.");
     }
 }
示例#24
0
        private async Task DeleteExpenseAsync(Expense expense)
        {
            if (await Js.InvokeAsync <bool>("confirm",
                                            "Are you sure you want to delete this expense? " +
                                            "This action cannot be undone."))
            {
                await ExpenseService.DeleteExpense(expense.Id);

                ToastService.ShowSuccess($"The '{ expense.Name }' expense has been sucessfully deleted.", "Expense Deleted");

                Expenses.Remove(expense);
            }
        }
示例#25
0
        private async Task DeletePersonAsync(Person person)
        {
            if (await Js.InvokeAsync <bool>("confirm",
                                            "Are you sure you want to delete this person? " +
                                            "This will also remove all of their expenses and also any shared expenses on this account. " +
                                            "This action cannot be undone."))
            {
                await PersonService.DeletePersonAsync(person.Id);

                ToastService.ShowSuccess("A person and all of their expenses have been sucessfully deleted.", "Person Deleted");

                StateChanged?.Invoke();
            }
        }
示例#26
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");
            }
        }
示例#27
0
        private async Task Create()
        {
            // Refresh date so it is set to the actual save time
            _audit.Date = DateTime.Now;

            await AuditRepo.CreateAudit(_audit);

            //_audit.Date = DateTime.Now();
            ToastService.ShowSuccess($"Action successful." +
                                     $"Audit \"{_audit.TransTypeId}\" successfully added.");
            _audit = new Audit();
            _editContext.OnValidationStateChanged += ValidationChanged;
            _editContext.NotifyValidationStateChanged();
        }
示例#28
0
 protected void Submit()
 {
     if (_item != null)
     {
         ParentItem.AddItem(_item);
         Repository.Save(ParentItem);
         BlazoredModal.Close(ModalResult.Ok <Item>(_item));
         ToastService.ShowSuccess("Item inbegrepen");
     }
     else
     {
         ToastService.ShowWarning("Selecteer een item.");
     }
 }
示例#29
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");
            }
        }
示例#30
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");
            }
        }