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); }
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); } }
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); } }
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); }
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); } }
public static void AddUsernameAndPassword(Employee employee) { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); db.Employees.InsertOnSubmit(employee); db.SubmitChanges(); }
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); }
public static IQueryable <Client> RetrieveClients() { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); var clients = db.Clients.Select(c => c); return(clients); }
public static IQueryable <USState> GetStates() { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); var states = db.USStates.Select(s => s); return(states); }
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); }
public static Animal GetAnimalByID(int iD) { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); var animal = db.Animals.Where(a => a.ID == iD).FirstOrDefault(); return(animal); }
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); }
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(); }
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); }
public static IQueryable <AnimalShotJunction> GetShots(Animal animal) { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); var shots = db.AnimalShotJunctions.Where(s => s.Animal.ID == animal.ID); return(shots); }
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); }
public static Shot GetShot(int shotId) { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); var shot = db.Shots.Where(s => s.ID == shotId).First(); return(shot); }
public static Animal[] GetAvailableAnimals() { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); var animals = db.Animals.Where(a => a.adoptionStatus.ToLower() != "adopted").ToArray(); return(animals); }
public static void RemoveAnimal(Animal animal) { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); db.Animals.DeleteOnSubmit(animal); db.SubmitChanges(); }
public static void GetPendingAdoptions() { HumaneSocietyDataContext getpendingadoptions = new HumaneSocietyDataContext(); var pending = getpendingadoptions.Animals.Where(c => c.name == userInput).Select(c => c.location); return(pending); }
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); }
public static DietPlan[] GetDietPlans() { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); var diets = db.DietPlans.ToArray(); return(diets); }
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); }
public static Room[] GetRooms() { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); var rooms = db.Rooms.ToArray(); return(rooms); }
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); }
public static void AddAnimal(Animal animal) { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); db.Animals.InsertOnSubmit(animal); db.SubmitChanges(); }
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); }
private static void CreateEmployee(Employee employee) { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); db.Employees.InsertOnSubmit(employee); db.SubmitChanges(); }