Exemple #1
0
        public async Task SubmitAsync()
        {
            if (Customers.Exists(x => x.UserId == Model.UserId && x.ProductId == Model.ProductId))
            {
                msg = $"{Model.User.Name} already has {Model.Product.Name}";
                return;
            }
            else
            {
                msg = null;
            }

            isLoading = true;

            var response = await HttpClient.PostAsJsonAsync("api/products/customers", Model);

            var customer = await response.Content.ReadFromJsonAsync <MProductCustomer>();

            customer.Product = Model.Product;
            customer.User    = Model.User;

            await OnCustomerAdded.InvokeAsync(customer);

            isLoading = false;

            ResetSearches();
            Model = DefaultModel;
            await JsRuntime.HideModalAsync(nameof(AddCustomerModal));
        }