Beispiel #1
0
        internal static Employee RetrieveEmployeeUser(string email, int employeeNumber)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            Employee employee           = (Employee)(db.Employees.Where(e => e.email.Equals(email) && e.employeeNumber.Equals(employeeNumber)));

            return(employee);
        }
Beispiel #2
0
        public static int GetAddress(string streetAddress, int zipCode, int state)
        {
            HumaneSocietyDataContext context = new HumaneSocietyDataContext();

            var address = (from u in context.UserAddresses where u.addessLine1 == streetAddress && u.zipcode == zipCode select u).FirstOrDefault();

            if (address.ID >= 0)
            {
                return(address.ID);
            }
            else
            {
                UserAddress newAddress = new UserAddress();
                newAddress.addessLine1 = streetAddress;
                newAddress.zipcode     = zipCode;
                newAddress.USState.ID  = state;
                context.UserAddresses.InsertOnSubmit(newAddress);
                try
                {
                    context.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                return(newAddress.ID);
            }
        }
Beispiel #3
0
        public static void Adopt(Animal animal, Client client)
        {
            HumaneSocietyDataContext context = new HumaneSocietyDataContext();
            var junction = (from j in context.ClientAnimalJunctions where j.animal == animal.ID && j.client == client.ID select j).FirstOrDefault();

            junction.approvalStatus = "pending";
            var animalInContext = (from a in context.Animals where a.ID == animal.ID select a).FirstOrDefault();

            animalInContext.adoptionStatus = "pending";
            context.ClientAnimalJunctions.InsertOnSubmit(junction);
            try
            {
                context.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            context.Animals.InsertOnSubmit(animalInContext);
            try
            {
                context.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #4
0
        private IQueryable <Animal> SearchForAnimal(int iD)
        {
            HumaneSocietyDataContext context = new HumaneSocietyDataContext();
            var animals = (from data in context.Animals where data.ID == iD select data);

            return(animals);
        }
Beispiel #5
0
        public static void UpdatePetFriendly(Animal animal, string update)
        {
            HumaneSocietyDataContext context = new HumaneSocietyDataContext();
            var  animalInContext             = (from a in context.Animals where a.ID == animal.ID select a).FirstOrDefault();
            bool petFriendly;

            if (update.ToLower() == "yes")
            {
                petFriendly = true;
            }
            else
            {
                petFriendly = false;
            }
            animalInContext.petFriendly = petFriendly;
            //context.Animals.InsertOnSubmit(animalInContext);
            try
            {
                context.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #6
0
        public static void AddUsernameAndPassword(Employee employee)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

            db.Employees.InsertOnSubmit(employee);
            db.SubmitChanges();
        }
Beispiel #7
0
        public static Animal GetAnimal()
        {
            HumaneSocietyDataContext database = new HumaneSocietyDataContext();
            Animal animal = new Animal();

            Console.WriteLine("\nEnter animal's ID: ");
            try
            {
                int  choice;
                bool isNumber = int.TryParse(Console.ReadLine(), out choice);
                foreach (var a in database.Animals)
                {
                    if (a.ID == choice)
                    {
                        animal = a;
                        break;
                    }
                }
            }catch
            {
                Console.WriteLine("You did not enter a valid ID for a current animal at the Humane Society.");
                Console.WriteLine("Hit [ENTER] to return to the Main Menu....");
                Console.ReadKey();
                Console.Clear();
                Menu();
            }
            Console.Clear();
            return(animal);
        }
Beispiel #8
0
        public static IQueryable <Client> RetrieveClients()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var clients = db.Clients.Select(c => c);

            return(clients);
        }
Beispiel #9
0
        public static IQueryable <USState> GetStates()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var states = db.USStates.Select(s => s);

            return(states);
        }
Beispiel #10
0
        public static Client GetClient(string userName, string password)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var resultClient            = db.Clients.Where(c => c.userName == userName && c.pass == password).FirstOrDefault();

            return(resultClient);
        }
Beispiel #11
0
        public static Animal GetAnimalByID(int iD)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var animal = db.Animals.Where(a => a.ID == iD).FirstOrDefault();

            return(animal);
        }
Beispiel #12
0
        public static IQueryable <ClientAnimalJunction> GetUserAdoptionStatus(Client client)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var pendingAdoptions        = db.ClientAnimalJunctions.Where(p => p.Client1 == client).Select(p => p);

            return(pendingAdoptions);
        }
Beispiel #13
0
        public static IQueryable <ClientAnimalJunction> GetPendingAdoptions()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var adoptions = db.ClientAnimalJunctions.Where(a => a.approvalStatus.ToLower() == "pending");

            return(adoptions);
        }
        public static void ImportCSVFile()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            string strReadFile          = @"C:\Users\Esteban\Desktop\Projects\HumaneSocietyStarter\animals.csv";
            int    startLine            = 1;
            int    lineCount            = 3;
            var    fileLines            = File.ReadAllLines(strReadFile).Skip((startLine)).Take(lineCount).ToList();

            //List<Animal> list = new List<Animal>();
            foreach (string line in fileLines)
            {
                string[] temp = line.Split(',');
                if (temp.Length >= 2)
                {
                    Animal animal = new Animal();
                    animal.AnimalId       = Convert.ToInt32(temp[0].Trim());
                    animal.Name           = temp[1].Trim();
                    animal.SpeciesId      = Convert.ToInt32(temp[2].Trim());
                    animal.Weight         = Convert.ToInt32(temp[3].Trim());
                    animal.Age            = Convert.ToInt32(temp[4].Trim());
                    animal.DietPlanId     = Convert.ToInt32(temp[5].Trim());
                    animal.Demeanor       = temp[6].Trim();
                    animal.KidFriendly    = Convert.ToBoolean(temp[7].Trim());
                    animal.PetFriendly    = Convert.ToBoolean(temp[8].Trim());
                    animal.Gender         = temp[9].Trim();
                    animal.AdoptionStatus = temp[10].Trim();
                    animal.EmployeeId     = Convert.ToInt32(temp[11].Trim());

                    db.Animals.InsertOnSubmit(animal);
                }
            }
            db.SubmitChanges();
        }
Beispiel #15
0
        public static Employee EmployeeLogin(string userName, string password)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var employeeLogin           = db.Employees.Where(e => e.userName == userName && e.pass == password).FirstOrDefault();

            return(employeeLogin);
        }
Beispiel #16
0
        public static IQueryable <AnimalShotJunction> GetShots(Animal animal)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var shots = db.AnimalShotJunctions.Where(s => s.Animal.ID == animal.ID);

            return(shots);
        }
Beispiel #17
0
        public static Employee RetrieveEmployeeUser(string email, int employeeNumber)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var employeeUser            = db.Employees.Where(e => e.email == email && e.employeeNumber == employeeNumber).FirstOrDefault();

            return(employeeUser);
        }
Beispiel #18
0
        public static Shot GetShot(int shotId)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var shot = db.Shots.Where(s => s.ID == shotId).First();

            return(shot);
        }
Beispiel #19
0
        public static Animal[] GetAvailableAnimals()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var animals = db.Animals.Where(a => a.adoptionStatus.ToLower() != "adopted").ToArray();

            return(animals);
        }
Beispiel #20
0
        public static void RemoveAnimal(Animal animal)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

            db.Animals.DeleteOnSubmit(animal);
            db.SubmitChanges();
        }
Beispiel #21
0
        public static void GetPendingAdoptions()
        {
            HumaneSocietyDataContext getpendingadoptions = new HumaneSocietyDataContext();
            var pending = getpendingadoptions.Animals.Where(c => c.name == userInput).Select(c => c.location);

            return(pending);
        }
Beispiel #22
0
        public static Breed[] GetBreeds()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var breeds = db.Breeds.ToArray();

            return(breeds);
        }
        private IQueryable <Animal> SearchForAnimal(int iD)
        {
            HumaneSocietyDataContext context = new HumaneSocietyDataContext();
            var animals = (from animal in context.Animals where animal.AnimalId == iD select animal);

            return(animals);
        }
Beispiel #24
0
        public static DietPlan[] GetDietPlans()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var diets = db.DietPlans.ToArray();

            return(diets);
        }
Beispiel #25
0
        public static IEnumerable <AnimalShotJunction> GetShots(Animal animal) //var shots ---List<string> shotInfo
        {
            HumaneSocietyDataContext context = new HumaneSocietyDataContext();
            var shots = (from j in context.AnimalShotJunctions where j.Animal_ID == animal.ID select j);

            return(shots);
        }
Beispiel #26
0
        public static Room[] GetRooms()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var rooms = db.Rooms.ToArray();

            return(rooms);
        }
Beispiel #27
0
        public static int GetClientAddressKey(string streetAddress, int zipCode, int state)
        {
            HumaneSocietyDataContext context = new HumaneSocietyDataContext();
            var stateToUpdate = (from row in context.USStates where row.ID == state select row).FirstOrDefault();

            if (stateToUpdate != null)
            {
            }
            int addressNumber;
            var clientAddress = from row in context.UserAddresses where row.addessLine1 == streetAddress && row.zipcode == zipCode && row.USState.ID == state select row.ID;

            if (clientAddress.ToList().Count > 0)
            {
                addressNumber = clientAddress.ToList()[0];
            }
            else
            {
                UserAddress userAddress = new UserAddress();
                userAddress.zipcode     = zipCode;
                userAddress.addessLine1 = streetAddress;
                userAddress.USState.ID  = state;
                context.UserAddresses.InsertOnSubmit(userAddress);
                context.SubmitChanges();
                var addressKey = from row in context.UserAddresses where row.addessLine1 == streetAddress && row.zipcode == zipCode && row.USState.ID == state select userAddress.ID;
                addressNumber = addressKey.ToList()[0];
            }
            return(addressNumber);
        }
Beispiel #28
0
        public static void AddAnimal(Animal animal)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

            db.Animals.InsertOnSubmit(animal);
            db.SubmitChanges();
        }
Beispiel #29
0
        public static void ReadEmployee(Employee employee, string read)
        {
            HumaneSocietyDataContext context = new HumaneSocietyDataContext();
            var employeeRecord = (from e in context.Employees where e.ID == employee.ID select e).FirstOrDefault();

            UserInterface.DisplayEmployeeInfo(employeeRecord);
        }
Beispiel #30
0
        private static void CreateEmployee(Employee employee)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

            db.Employees.InsertOnSubmit(employee);
            db.SubmitChanges();
        }