Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 6
0
        public static void AddUsernameAndPassword(Employee employee)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

            db.Employees.InsertOnSubmit(employee);
            db.SubmitChanges();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
        public static IQueryable <Client> RetrieveClients()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var clients = db.Clients.Select(c => c);

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

            return(states);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 11
0
        public static Animal GetAnimalByID(int iD)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var animal = db.Animals.Where(a => a.ID == iD).FirstOrDefault();

            return(animal);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 13
0
        public static IQueryable <ClientAnimalJunction> GetPendingAdoptions()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var adoptions = db.ClientAnimalJunctions.Where(a => a.approvalStatus.ToLower() == "pending");

            return(adoptions);
        }
Ejemplo n.º 14
0
        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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 18
0
        public static Shot GetShot(int shotId)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var shot = db.Shots.Where(s => s.ID == shotId).First();

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

            return(animals);
        }
Ejemplo n.º 20
0
        public static void RemoveAnimal(Animal animal)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

            db.Animals.DeleteOnSubmit(animal);
            db.SubmitChanges();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 22
0
        public static Breed[] GetBreeds()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var breeds = db.Breeds.ToArray();

            return(breeds);
        }
Ejemplo n.º 23
0
        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);
        }
Ejemplo n.º 24
0
        public static DietPlan[] GetDietPlans()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var diets = db.DietPlans.ToArray();

            return(diets);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 26
0
        public static Room[] GetRooms()
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            var rooms = db.Rooms.ToArray();

            return(rooms);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 28
0
        public static void AddAnimal(Animal animal)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

            db.Animals.InsertOnSubmit(animal);
            db.SubmitChanges();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 30
0
        private static void CreateEmployee(Employee employee)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

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