protected override async Task OnInitializedAsync() { AppData.OnChange += StateHasChanged; if (AppData.Categories.Count == 0) { _categories = AppData.Categories = await CategoryWebService.GetCategories(); } else { _categories = AppData.Categories; } }
private async Task HandleCategorySubmit() { if (Category.Id == default) { // Add // Save into Db await CategoryWebService.AddCategory(Category); // Return to modal parent await CategoryModal.Close(ModalResult.Ok(Category)); } else { // Edit // Update Db await CategoryWebService.EditCategory(Category); // Return to modal parent await CategoryModal.Close(ModalResult.Ok(Category)); } }
private async Task OnDeleteCategory(CategoryDto category) { var confirmParams = new ModalParameters(); confirmParams.Add(nameof(Confirm.ConfirmationMessage), $"آیا از حذف دسته {category.CategoryName} مطمئن میباشید؟"); var confirmModal = ModalService.Show <Confirm>("تایید حذف", confirmParams); var result = await confirmModal.Result; if (!result.Cancelled && (bool)result.Data) { await CategoryWebService.DeleteCategory(category); ToastService.ShowSuccess("حذف دسته با موفقیت انجام شد"); await LoadTableData(); } }
protected override async Task OnInitializedAsync() { var authState = await AuthenticationStateTask; if (authState.User.Identity == null) { return; } if (authState.User.Identity.IsAuthenticated) { var categories = await CategoryWebService.GetCategories(); //Administrator is super role which is not in categories var rolesCanSeeManageBook = new List <string> { "Administrator" }; rolesCanSeeManageBook.AddRange(categories.Select(c => c.AdminRole)); _categoriesAdminRoles = string.Join(",", rolesCanSeeManageBook); } }
public CategoryController() { _categoryService = new CategoryWebService(); }
private async Task LoadTableData() { _categories = await CategoryWebService.GetCategories(); StateHasChanged(); }