protected override async Task OnInitializedAsync()
        {
            int.TryParse(ProductId, out var productId);
            Product = await ProductDataService.Get(productId);

            CategoryId = Product.CategoryId.ToString();

            Categories = await CategoryDataService.Get();

            Categories.Insert(0, new Category {
                CategoryId = -1, Name = "Please select"
            });
        }
Example #2
0
        protected override async Task OnInitializedAsync()
        {
            Products = await ProductDataService.Get();

            Categories = await CategoryDataService.Get();

            foreach (var product in Products)
            {
                Model.ProductViewItems.Add(new ProductViewItem
                {
                    CategoryId   = product.CategoryId,
                    CategoryName = Categories.First(x => x.CategoryId == product.CategoryId).Name,
                    Image        = product.Image,
                    IsAvailable  = product.IsAvailable,
                    Name         = product.Name,
                    ProductId    = product.ProductId,
                    UnitPrice    = product.UnitPrice
                });
            }
        }
Example #3
0
        protected override async Task OnInitializedAsync()
        {
            Categories = await CategoryDataService.Get();

            Products = await ProductDataService.Get();
        }
 protected override async Task OnInitializedAsync()
 {
     int.TryParse(CategoryId, out var categoryId);
     Category = await CategoryDataService.Get(categoryId);
 }
 public async void AddCategoryDialog_OnDialogClose()
 {
     Categories = (await CategoryDataService.Get());
     StateHasChanged();
 }