Esempio n. 1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            string catalogName = tbCatalogName.Text;

            bool isValid = true;

            if (string.IsNullOrWhiteSpace(catalogName))
            {
                errorProvider.SetError(tbCatalogName, "Bat buoc");
                isValid = false;
            }
            else
            {
                errorProvider.SetError(tbCatalogName, null);
            }

            if (!isValid)
            {
                return;
            }

            var res = await CatalogController.CreateCatalog(new Catalog
            {
                CatalogName = catalogName,
            });

            if (!res.IsSuccess)
            {
                Notification.Error(HandleError <CatalogErrorMessage> .GetErrorString(res.Messages));
                return;
            }

            Notification.Success("Success");

            _catalogListPage.renderCatalogs();

            this.Hide();
        }