Exemplo n.º 1
0
        //public int AddNewMeal()
        //{
        //    string nameOfMeal;
        //    var choosenDay = GetDay();
        //    do
        //    {
        //        Console.WriteLine("Please type name of meal...");
        //        nameOfMeal = Console.ReadLine();
        //    }
        //    while (choosenDay.mealList.Contains(choosenDay.mealList.FirstOrDefault(s => s.NameOfMeal == nameOfMeal)));
        //    var addedMealId = _dayService.AddNewMealinDay(nameOfMeal, choosenDay);
        //    return addedMealId;
        //}
        public int AddNewDay()
        {
            int      day, month, year;
            DateTime dateTime;

            Console.Clear();
            do
            {
                Console.WriteLine("Type day of month... (example: '18')");
                int.TryParse(Console.ReadLine(), out day);
                Console.WriteLine("Type number of month... (example: '3')");
                int.TryParse(Console.ReadLine(), out month);
                Console.WriteLine("Type year... (example: '1998')");
                int.TryParse(Console.ReadLine(), out year);
            }while (!DateTime.TryParse($"{day}/{month}/{year}", out dateTime) || IsDayExistinginDatabase(dateTime));
            var holder = _dayService.CreateNewDayByDateTime(dateTime, _mealService);

            return(holder.Id);
        }