Example #1
0
        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);
        }