Example #1
0
        protected void SaveButton_Click1(object sender, EventArgs e)
        {
            Profile newProfile = new Profile();

            newProfile.ProfileName = txtProfileName.Text;
            if (ProfileLogic.IsExists(txtProfileName.Text))
            {
                ShowNotification(false, string.Format("A Profile with this {0} already exists", txtProfileName.Text), "");
                return;
            }
            else
            {
                ProfileLogic.AddNewEntity(newProfile);
                // ShowNotification(true, "Sucessfully Created", "AddCategoryOrProfile.aspx");
            }
            if (hdnCategories.Value.Contains(","))
            {
                string[] categoryNames = hdnCategories.Value.Replace(" ", "_").Split(',');
                foreach (string c in categoryNames)
                {
                    Category newCategory = new Category();
                    newCategory.CategoryName = c;
                    newCategory.Profile      = newProfile;
                    if (CategoryLogic.IsExists(c))
                    {
                        ShowNotification(false, string.Format("A Category with this {0} already exists", c), "");
                        // return;
                    }
                    else
                    {
                        CategoryLogic.AddNewEntity(newCategory);
                        ShowNotification(true, "Sucessfully Created", "AddCategoryOrProfile.aspx");
                    }
                }
            }
            else
            {
                Category newCategory = new Category();
                newCategory.CategoryName = hdnCategories.Value.ToString();
                CategoryLogic.AddNewEntity(newCategory);
            }
        }