protected async Task ProviderEditClickHandler(MouseEventArgs e, string taxNumber) { IsFormShown = !IsFormShown; IsShown = !IsShown; FormTitle = "Szolgáltató módosítása"; AdminProviderVM = Mapper.Map <AdminProviderVM>((await ProviderService.GetAsync(x => x.TaxNumber.Equals(taxNumber))).FirstOrDefault()); ProviderVMEditContext = new EditContext(AdminProviderVM); await InvokeAsync(StateHasChanged); }
protected override async Task OnInitializedAsync() { base.OnInitialized(); ProviderVMs = Mapper.Map <List <ProviderVM> >(await ProviderService.GetAsync()); AdminProviderVM = new AdminProviderVM(); ProviderVMEditContext = new EditContext(AdminProviderVM); await InvokeAsync(StateHasChanged); }
protected async Task HandleSubmit() { if (ProviderVMEditContext.Validate()) { var provider = (await ProviderService.GetAsync(x => x.TaxNumber.Equals(AdminProviderVM.TaxNumber))).FirstOrDefault(); if (provider == null) { await ProviderService.AddAsync(Mapper.Map <Provider>(AdminProviderVM)); } else { provider = Mapper.Map(AdminProviderVM, provider); ProviderService.Update(provider); } await ProviderService.SaveChangesAsync(AppUser.Instance.FullName); } ProviderVMs = Mapper.Map <List <ProviderVM> >(await ProviderService.GetAsync()); AdminProviderVM = new AdminProviderVM(); ProviderVMEditContext = new EditContext(AdminProviderVM); IsFormShown = !IsFormShown; IsShown = !IsShown; await InvokeAsync(StateHasChanged); }