Beispiel #1
0
        public static Category ChooseCategory()
        {
            string insertData;

            ServicesActions.ListCategories();
            Category cat = null;
            bool     ok  = false;

            do
            {
                Console.WriteLine("CHOOSE CATEGORY : ");
                insertData = Console.ReadLine();
                if (CommonLib.ValidateNumEntrance(insertData))
                {
                    cat = _adminMgm.GetCategory(int.Parse(insertData));
                }
                else
                {
                    cat = _adminMgm.GetCategory(insertData);
                }
                if (cat != null)
                {
                    return(cat);
                }
                Console.WriteLine("GET SERVICES FROM ALL CATEGORIES ? (Y/N)");
                insertData = Console.ReadLine();
                if (insertData.ToUpper() != "N")
                {
                    ok = true;
                }
            } while (!ok);
            return(null);
        }
        private void Btn_nuevaCat_Click(object sender, RoutedEventArgs e)
        {
            if (!ValidateEntranceCat())
            {
                return;
            }

            var existst = admin.GetCategory(Txt_NombreCat.Text);

            if (existst != null)
            {
                MessageBox.Show("Categoría duplicada");
                return;
            }
            admin.InsertOrUpdate(new Category
            {
                Name = Txt_NombreCat.Text
            });
            ShowCategories();
        }