Exemplo n.º 1
0
 private void GetPassword()
 {
     UserInterface.DisplayUserOptions("Please enter your password: (CaSe SeNsItIvE)");
     employee.Password = UserInterface.GetUserInput();
 }
Exemplo n.º 2
0
 private void UpdateIncome()
 {
     UserInterface.DisplayUserOptions("What is your household income? (If you would like to omit it enter 0)");
     client.Income = UserInterface.GetIntegerData();
     Query.updateClient(client);
 }
Exemplo n.º 3
0
        // TODO: Animal Multi-Trait Search
        internal static IQueryable <Animal> SearchForAnimalsByMultipleTraits(Dictionary <int, string> updates) // parameter(s)?
        {
            bool searchForTrait = true;
            var  animals        = db.Animals.ToList();

            while (searchForTrait == true)
            {
                List <string> options = new List <string>()
                {
                    "Select Update:", "1. Category", "2. Name", "3. Age", "4. Demeanor", "5. Kid friendly", "6. Pet friendly", "7. Weight", "8. Finished", "You will be prompted again for any additional updates."
                };
                UserInterface.DisplayUserOptions(options);
                var userInput = UserInterface.GetIntegerData();
                switch (userInput)
                {
                case 1:
                    UserInterface.DisplayUserOptions("Enter an animal category to search by:");
                    string searchCategory = UserInterface.GetUserInput();
                    animals = animals.Where(c => c.Category.Name == searchCategory).Select(c => c).ToList();
                    break;

                case 2:
                    UserInterface.DisplayUserOptions("Enter an animal name to search by:");
                    string searchName = UserInterface.GetUserInput();
                    animals = animals.Where(n => n.Name == searchName).Select(n => n).ToList();
                    break;

                case 3:
                    UserInterface.DisplayUserOptions("Enter an animal age to search by:");
                    int searchAge = UserInterface.GetIntegerData();
                    animals = animals.Where(a => a.Age == searchAge).Select(a => a).ToList();
                    break;

                case 4:
                    UserInterface.DisplayUserOptions("Enter an animal demeanor to search by:");
                    string searchDemeanor = UserInterface.GetUserInput();
                    animals = animals.Where(d => d.Demeanor == searchDemeanor).Select(d => d).ToList();
                    break;

                case 5:
                    bool?searchKidFriendly = UserInterface.GetBitData("Search if an animal is kid friendly:");
                    animals = animals.Where(k => k.KidFriendly == searchKidFriendly).Select(k => k).ToList();
                    break;

                case 6:
                    bool?searchPetFriendly = UserInterface.GetBitData("Search if an animal is pet frirndly:");
                    animals = animals.Where(p => p.PetFriendly == searchPetFriendly).Select(p => p).ToList();
                    break;

                case 7:
                    UserInterface.DisplayUserOptions("Enter an animal weight to search by:");
                    int searchWeight = UserInterface.GetIntegerData();
                    animals = animals.Where(w => w.Weight == searchWeight).Select(w => w).ToList();
                    break;

                default:
                    Console.WriteLine("Please make a valid selection.");
                    break;
                }
                Console.WriteLine("Would you like to search again?");;
                string input = UserInterface.GetUserInput();
                if (input.ToLower() == "yes" || input.ToLower() == "y")
                {
                    searchForTrait = true;
                }
                else if (input.ToLower() == "no" || input.ToLower() == "n")
                {
                    searchForTrait = false;
                }
                else
                {
                    UserInterface.DisplayUserOptions("Input not recognized please try again");
                }
            }
            return(animals);
            //throw new NotImplementedException();
        }
Exemplo n.º 4
0
 public Client()
 {
     UI         = new UserInterface();
     management = new Management();
     // will need to send in the new management class that is intatiated in the program
 }
Exemplo n.º 5
0
        //// TODO Items: ////

        // TODO: Allow any of the CRUD operations to occur here
        internal static void RunEmployeeQueries(Employee employee, string crudOperation)
        {
            switch (crudOperation)
            {
            case "create":
                var checkEmployeeNumber = db.Employees.Where(e => e.EmployeeNumber == employee.EmployeeNumber).FirstOrDefault();
                if (checkEmployeeNumber == null)
                {
                    var checkEmployeeEmail = db.Employees.Where(e => e.Email == employee.Email).FirstOrDefault();
                    if (checkEmployeeEmail == null)
                    {
                        db.Employees.InsertOnSubmit(employee);
                        db.SubmitChanges();
                    }
                    else
                    {
                        UserInterface.DisplayUserOptions("Employee ID number already exists.");
                    }
                }
                else
                {
                    UserInterface.DisplayUserOptions("Employee e-mail already exists.");
                }
                break;

            case "delete":
                employee = db.Employees.Where(e => e.UserName == employee.UserName && e.EmployeeId == employee.EmployeeId).SingleOrDefault();
                db.Employees.DeleteOnSubmit(employee);
                db.SubmitChanges();
                break;

            case "read":
                employee = db.Employees.Where(e => e.EmployeeNumber == employee.EmployeeNumber).FirstOrDefault();
                List <string> employeeRead = new List <string>()
                {
                    "Employee name: " + employee.FirstName + "" + employee.LastName,
                    "Employee username: "******"Employee number: " + employee.EmployeeNumber,
                    "Employee e-mail" + employee.Email,
                };
                UserInterface.DisplayUserOptions(employeeRead);
                break;

            case "update":
                employee = db.Employees.Where(e => e.EmployeeNumber == employee.EmployeeNumber).FirstOrDefault();
                List <string> employeeUpdate = new List <string>()
                {
                    "Employee name: " + employee.FirstName + "" + employee.LastName,
                    "Employee username: "******"Employee number: " + employee.EmployeeNumber,
                    "Employee e-mail" + employee.Email,
                    "Employee password: "******"first name", "the employee's");
                employee.LastName       = UserInterface.GetStringData("last name", "the employee's");
                employee.EmployeeNumber = int.Parse(UserInterface.GetStringData("employee number", "the employee's"));
                employee.Email          = UserInterface.GetStringData("email", "the employee's");
                break;
            }
            //throw new NotImplementedException();
        }
Exemplo n.º 6
0
        internal static void UpdateAnimal(int animalId, Dictionary <int, string> updates)
        {
            try
            {
                if (db.Animals.FirstOrDefault(a => a.AnimalId == animalId) is null)
                {
                    UserInterface.DisplayUserOptions("Animal does not exist in database, cannot update.");
                    return;
                }
            }
            catch (Exception ex)
            {
                UserInterface.DisplayUserOptions(ex.Message);
            }


            foreach (var update in updates)
            {
                switch (update.Key)
                {
                case 1:
                    db.Animals.Where(a => a.AnimalId == animalId).FirstOrDefault().Category = db.Categories.Where(b => b.Name == update.Value).FirstOrDefault();
                    break;

                case 2:
                    db.Animals.Where(a => a.AnimalId == animalId).FirstOrDefault().Name = update.Value;
                    break;

                case 3:
                    int age;
                    if (Int32.TryParse(update.Value, out age))
                    {
                        db.Animals.Where(a => a.AnimalId == animalId).FirstOrDefault().Age = age;
                    }
                    ;
                    break;

                case 4:
                    db.Animals.Where(a => a.AnimalId == animalId).FirstOrDefault().Demeanor = update.Value;
                    break;

                case 5:
                    try
                    {
                        db.Animals.Where(a => a.AnimalId == animalId).FirstOrDefault().KidFriendly =
                            Convert.ToBoolean(update.Value);
                    }
                    catch (Exception e) { UserInterface.DisplayUserOptions(e.Message); }
                    break;

                case 6:
                    try
                    {
                        db.Animals.Where(a => a.AnimalId == animalId).FirstOrDefault().PetFriendly =
                            Convert.ToBoolean(update.Value);
                    }
                    catch (Exception e) { UserInterface.DisplayUserOptions(e.Message); }
                    break;

                case 7:
                    int weight;
                    if (Int32.TryParse(update.Value, out weight))
                    {
                        db.Animals.Where(a => a.AnimalId == animalId).FirstOrDefault().Weight = weight;
                    }
                    break;

                default:
                    break;
                }
            }
            db.SubmitChanges();
        }
Exemplo n.º 7
0
 private static void UpdateHomeSize(Client client)
 {
     Console.Clear();
     UserInterface.DisplayUserOptions("What is your home size? (small, medium, large)");
 }
Exemplo n.º 8
0
        private static void ReadEmployee(Employee employee)
        {
            Employee foundEmployee = db.Employees.FirstOrDefault(a => a.EmployeeNumber == employee.EmployeeNumber);

            UserInterface.DisplayEmployeeInfo(foundEmployee);
        }
Exemplo n.º 9
0
        public void AddCSVFile(string fileName)
        {
            try
            {
                using (TextFieldParser parser = new TextFieldParser(@fileName))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");

                    while (!parser.EndOfData)
                    {
                        string[] animalTrait = parser.ReadFields();

                        Animal animalToAdd = new Animal();
                        animalToAdd.Name = animalTrait[0].Trim('"');
                        int?intParseValue = UserInterface.GetCsvIntData(animalTrait[2]);
                        animalToAdd.Weight = intParseValue;
                        string testedInput = UserInterface.CsvNullChecker(animalTrait[1]);
                        while (testedInput == null)
                        {
                            UserInterface.DisplayUserOptions("Please enter the animal`s species: ");
                            string input = Console.ReadLine();
                            intParseValue = Query.GetCategoryId(input);
                            if (intParseValue != null)
                            {
                                testedInput = "Not null";
                            }
                        }
                        animalToAdd.CategoryId = intParseValue;
                        intParseValue          = UserInterface.GetCsvIntData(animalTrait[3]);
                        animalToAdd.Age        = intParseValue;
                        intParseValue          = UserInterface.GetCsvIntData(animalTrait[4]);
                        animalToAdd.DietPlanId = intParseValue;
                        animalToAdd.Demeanor   = animalTrait[5].Trim('"');
                        bool?newFriendlyStatus = UserInterface.GetCsvBoolData(animalTrait[6]);
                        animalToAdd.KidFriendly    = newFriendlyStatus;
                        newFriendlyStatus          = UserInterface.GetCsvBoolData(animalTrait[7]);
                        animalToAdd.PetFriendly    = newFriendlyStatus;
                        animalToAdd.Gender         = animalTrait[8];
                        animalToAdd.AdoptionStatus = animalTrait[9].Trim('"');
                        intParseValue          = UserInterface.GetCsvIntData(animalTrait[10]);
                        animalToAdd.EmployeeId = intParseValue;

                        if (Query.CheckIfEmptyRoom())
                        {
                            Query.AddAnimal(animalToAdd);
                            Query.PlaceAnimalIntoRoom(animalToAdd.AnimalId);
                        }
                        else
                        {
                            UserInterface.DisplayUserOptions("There are no open rooms at this time. The animal has not been admitted. Press any key to continue.");
                            Console.ReadLine();
                            RunUserMenus();
                        }
                    }
                    RunUserMenus();
                }
            }
            catch
            {
                UserInterface.DisplayUserOptions("There is something wrong with the file you are attempting to load or the file does not exist. Please check it and try again. Press any key to continue.");
                Console.ReadLine();
                RunUserMenus();
            }
        }