Beispiel #1
0
 private Token TokenExists()
 {
     if (CommonLib.ValidateNumEntrance(Txt_Id.Text))
     {
         return(AdminMgm.GetTokenById(int.Parse(Txt_Id.Text)));
     }
     return(null);
 }
Beispiel #2
0
        private Token GetToken()
        {
            Token  token = null;
            string o;

            Console.WriteLine("GET TOKEN TO REMOVE");
            Console.WriteLine("-------------------");
            do
            {
                Console.WriteLine("INSERT EXISTING TOKEN ID OR BLANK TO EXIT : ");
                o = Console.ReadLine().ToUpper();
                if (String.IsNullOrWhiteSpace(o))
                {
                    ShowTokenMenu();
                    return(null);
                }
                if (CommonLib.ValidateNumEntrance(o))
                {
                    token = _adminMgm.GetTokenById(int.Parse(o));
                }
            } while (token == null);

            return(token);
        }
Beispiel #3
0
        public static void NewService()
        {
            Service service = new Service();
            string  insertData;

            Console.WriteLine("SERVICE FORM");
            Console.WriteLine("------------");

            Console.WriteLine("NAME : ");
            insertData = Console.ReadLine();
            if (!String.IsNullOrWhiteSpace(insertData))
            {
                service.Name = insertData;
            }

            Console.WriteLine("DESCRIPTION : ");
            insertData = Console.ReadLine();
            if (!String.IsNullOrWhiteSpace(insertData))
            {
                service.Description = insertData;
            }

            List <Category> cats = _adminMgm.GetCategories();

            foreach (Category c in cats)
            {
                Console.WriteLine(c.ToString());
            }
            Console.WriteLine("CATEGORY : ");
            insertData = Console.ReadLine();
            if (!String.IsNullOrWhiteSpace(insertData))
            {
                service.Description = insertData;
            }

            User userProv = null;

            do
            {
                Console.WriteLine("USER PROVIDER : ");
                insertData = Console.ReadLine();
                long n = CommonLib.ValidateNumEntrance(insertData) ? (long.Parse(insertData)) : 1L;
                userProv = UserManagement.GetInstance().GetUser(n);
                if (userProv != null)
                {
                    service.ProviderID = n;
                    service.Provider   = userProv;
                }
            } while (userProv == null);

            Token token = null;
            bool  ok    = false;

            Console.WriteLine("PRICE : ");
            do
            {
                List <Token> tokens = _adminMgm.GetTokens();
                foreach (Token t in tokens)
                {
                    Console.WriteLine(t.ToString());
                }

                Console.WriteLine("INSERT TOKEN ID : ");
                insertData = Console.ReadLine();
                int n = CommonLib.ValidateNumEntrance(insertData) ? (int.Parse(insertData)) : 1;
                token = _adminMgm.GetTokenById(n);
                if (token != null)
                {
                    Console.WriteLine("INSERT QUANTITY OF TOKENS " + token.Name);
                    insertData = Console.ReadLine();
                    int q = CommonLib.ValidateNumEntrance(insertData) ? (int.Parse(insertData)) : 1;

                    if (service.Price == null)
                    {
                        service.Price = new List <Token>();
                    }

                    for (int i = 0; i <= q; i++)
                    {
                        service.Price.Add(token);
                    }
                }
                Console.WriteLine("WANT TO ADD MORE TOKENS TO THE SERVICE ? (Y/N)");
                insertData = Console.ReadLine();
                if (insertData.ToUpper() == "Y")
                {
                    ok = false;
                }
                else
                {
                    ok = true;
                }
            } while (!ok);

            InsertOrUpdate(userProv, service);
        }