Пример #1
0
        public static void AddCategoryMenu()
        {
            CurrentUser.PrintNotYoursCategories();
            Console.WriteLine("Enter category ID :");

            bool correctChoice = false;
            int  CatId         = 0;

            while (!correctChoice)
            {
                try {
                    CatId = Convert.ToInt32(Console.ReadLine());
                    if (CurrentUser.getNotYoursCategoriesId().Contains(CatId))
                    {
                        CurrentUser.AddSubCategory(db.Get <Category>(CatId));
                        correctChoice = true;
                    }
                    else
                    {
                        Console.WriteLine("Enter a correct ID :");
                    }
                } catch (Exception e) {
                    Debug.WriteLine("Exception : " + e);
                    Console.WriteLine("Enter a correct ID :");
                }
            }
            Console.WriteLine("Press a key to come back to the categories menu.");
            Console.ReadKey();
            User.categoriesMenu();
        }
Пример #2
0
        /// <summary>
        /// Ask the user for create his own subcategorie
        /// </summary>
        public static void userCategoryCreation(Profil currentProfil)
        {
            Console.WriteLine("Please select in what categories are you interested : ");
            List <Category> categories = db.Query <Category> ("SELECT * FROM Category");

            foreach (Category c  in categories)
            {
                Console.WriteLine("(ID " + c.Id + ") : " + c.Name + "(" + c.Description + ")");
            }

            Console.WriteLine("Enter categories IDs separated with '-' : ");
            List <string> listIds = new List <string> (Console.ReadLine().Split(new char[] { '-' }));

            foreach (string id in listIds)
            {
                try {
                    currentProfil.AddSubCategory(db.Get <Category> (Convert.ToInt32(id)));
                } catch (Exception e) {
                    Debug.WriteLine("Exception : " + e);
                    Console.WriteLine("The last ID was not correct. Precedents IDs were saved. You will be able to manage your categories later.");
                }
            }
        }
Пример #3
0
		/// <summary>
		/// Ask the user for create his own subcategorie 
		/// </summary>
		public static void userCategoryCreation(Profil currentProfil)
		{
			Console.WriteLine ("Please select in what categories are you interested : ");
			List<Category> categories = db.Query<Category> ("SELECT * FROM Category");
			foreach (Category c  in categories) {
				Console.WriteLine ("(ID " + c.Id +") : "+ c.Name +"("+c.Description+")");
			}

			Console.WriteLine ("Enter categories IDs separated with '-' : ");
			List<string> listIds = new List<string> (Console.ReadLine ().Split (new char[] { '-' }));

			foreach (string id in listIds) {
				try {
					currentProfil.AddSubCategory(db.Get<Category> (Convert.ToInt32(id)));
				} catch (Exception e) {
					Debug.WriteLine("Exception : "+e);
					Console.WriteLine ("The last ID was not correct. Precedents IDs were saved. You will be able to manage your categories later.");
				}
			}
		}