Esempio n. 1
0
        protected void btnSubmit_Click(Object sender, EventArgs e)
        {
            Tenant tenant = new Tenant();

            foreach (String fieldName in Request.Form)
            {
                if (fieldName.Contains("txtId"))
                {
                    tenant.id = int.Parse(Request.Form[fieldName]);
                }
                if (fieldName.Contains("txtName"))
                {
                    tenant.name = Request.Form[fieldName];
                }
                if (fieldName.Contains("txtAlias"))
                {
                    tenant.alias = Request.Form[fieldName];
                }
            }

            if ((String.IsNullOrEmpty(tenant.name)) || (String.IsNullOrEmpty(tenant.alias)))
            {
                EmbedClientScript.ShowErrorMessage(this, "Os valores informados não estão em um formato válido!");
                return;
            }

            if (!FieldParser.IsAlphaNumeric(tenant.name))
            {
                EmbedClientScript.ShowErrorMessage(this, "O identificador deve conter apenas letras e números!");
                return;
            }

            // Executa o conjunto de operações para a criação do Tenant
            TenantTransaction transaction = new TenantTransaction(tenant, dataAccess.GetConnection());

            transaction.Execute();
            EmbedClientScript.CloseWindow(this);
        }