Ejemplo n.º 1
0
        private void UpdateDietPlan()
        {
            Console.WriteLine("What diet plan would you like to change?");
            int    amountOfDietPlans = Query.DisplayAndCountAllDietPlans();
            string userInput         = Console.ReadLine();

            try
            {
                int dietPlanId = Convert.ToInt32(userInput);
                UserInterface.DisplayAboutToUpdate();
                DietPlan dietPlan = new DietPlan();
                if (amountOfDietPlans >= dietPlanId)
                {
                    dietPlan.Name             = UserInterface.GetStringDataWithoutIs("set the name to", "would you like to");
                    dietPlan.FoodType         = UserInterface.GetStringDataWithoutIs("set the food type to", "would you like to");
                    dietPlan.FoodAmountInCups = int.Parse(UserInterface.GetStringData("you would like to set for this diet plan", "amount of food in cups"));
                    Query.UpdateDietPlan(dietPlan, dietPlanId);
                    return;
                }
                else
                {
                    UserInterface.DisplayUserOptions("Input not accepted please try again");
                    UpdateDietPlan();
                    return;
                }
            }
            catch
            {
                UserInterface.DisplayUserOptions("Input not accepted please try again");
                UpdateDietPlan();
                return;
            }
        }
Ejemplo n.º 2
0
        private void UpdateEmployee()
        {
            Employee employee       = new Employee();
            int      employeeNumber = int.Parse(UserInterface.GetStringData("employee number you would like to change", "the employee's"));

            UserInterface.DisplayAboutToUpdate();
            employee.FirstName      = UserInterface.GetStringData("first name", "the employee's");
            employee.LastName       = UserInterface.GetStringData("last name", "the employee's");
            employee.EmployeeNumber = int.Parse(UserInterface.GetStringData("new employee number", "the employee's"));
            employee.Email          = UserInterface.GetStringData("email", "the employee's");
            try
            {
                Query.RunEmployeeQueries(employee, "update", employeeNumber);
                UserInterface.DisplayUserOptions("Employee update successful.");
            }
            catch
            {
                Console.Clear();
                UserInterface.DisplayUserOptions("Employee update unsuccessful please try again or type exit;");
                return;
            }
        }