public static void DeleteEmployee(Employee employee) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); var deletedEmployee = db.Employees.Where(c => c.employeeNumber == employee.employeeNumber).First(); db.Employees.DeleteOnSubmit(deletedEmployee); db.SubmitChanges(); }
public static void CreateEmployee(Employee employee) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); Employee newEmployee = employee; db.Employees.InsertOnSubmit(newEmployee); db.SubmitChanges(); }
public static void UpdateLastName(Client client) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); var clientData = db.Clients.Where(c => c.ID == client.ID).First(); clientData.lastName = client.lastName; db.SubmitChanges(); }
public static void UpdateAddress(Client client) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); var clientData = db.Clients.Where(c => c.ID == client.ID).First(); clientData.userAddress = client.userAddress; db.SubmitChanges(); }
public static void UpdateEmail(Client client) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); var clientData = db.Clients.Where(c => c.ID == client.ID).First(); clientData.email = client.email; db.SubmitChanges(); }
private static void UpdatePetWeight(Animal animal, string newValue) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); Animal animalUpdating = db.Animals.Where(c => c.ID == animal.ID).First(); animalUpdating.weight = Convert.ToInt32(newValue); UserInterface.DisplayUserOptions("Weight entered was not a number."); db.SubmitChanges(); }
private static void UpdatePetFriendly(Animal animal, string newValue) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); Animal animalUpdating = db.Animals.Where(c => c.ID == animal.ID).First(); bool petFriendlyUpdate = Boolean.TryParse(newValue, out petFriendlyUpdate); animalUpdating.petFriendly = petFriendlyUpdate; db.SubmitChanges(); }
private static void UpdateBreed(Animal animal, string newValue) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); Animal animalUpdating = db.Animals.Where(c => c.ID == animal.ID).First(); Breed newBreed = db.Breeds.Where(c => c.breed1 == newValue).First(); animalUpdating.breed = newBreed.ID; db.SubmitChanges(); }
private static void AddNewBreed(string breedName) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); Breed newBreed = new Breed(); newBreed.breed1 = breedName; newBreed.pattern = UserInterface.GetStringData("pattern", "the animal's"); db.Breeds.InsertOnSubmit(newBreed); db.SubmitChanges(); }
private static void AddNewDiet(string foodType, int foodAmount) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); DietPlan newDietPlan = new DietPlan(); newDietPlan.food = foodType; newDietPlan.amount = foodAmount; db.DietPlans.InsertOnSubmit(newDietPlan); db.SubmitChanges(); }
private static void UpdateCategory(Animal animal, string newValue) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); Animal animalUpdating = db.Animals.Where(c => c.ID == animal.ID).First(); var breed = db.Breeds.Where(c => c.ID == animalUpdating.breed).First(); var category = db.Catagories.Where(c => c.ID == breed.catagory).First(); category.catagory1 = newValue; breed.catagory = category.ID; db.SubmitChanges(); }
public static void UpdateEmployee(Employee employee) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); var updatedEmployee = db.Employees.Where(c => employee.employeeNumber == c.employeeNumber).First(); updatedEmployee.firsttName = employee.firsttName; updatedEmployee.lastName = employee.lastName; updatedEmployee.employeeNumber = employee.employeeNumber; updatedEmployee.email = employee.email; db.SubmitChanges(); }
public static void Adopt(object animal, Client client) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); var animalData = db.Animals.Where(a => a == animal).First(); var clientData = db.Clients.Where(c => c.ID == client.ID).First(); var clientJunctionData = db.ClientAnimalJunctions.Where(c => c.client == clientData.ID).Where(cj => cj.animal == animalData.ID).First(); clientJunctionData.approvalStatus = "pending"; animalData.adoptionStatus = "pending"; db.SubmitChanges(); }
private static void HandleCsvAnimals(string filePath) { var db = new HumaneSociety2DataContext(); var query = File.ReadLines(filePath) .SelectMany(line => line.Split(';')) .Where(csvLine => !String.IsNullOrWhiteSpace(csvLine)) .Select(csvLine => new { data = csvLine.Split(',') }) .Select(s => new { ID = Int32.Parse(s.data[0]), name = s.data[1], breed = IntOrNullParse(s.data[2]), weight = IntOrNullParse(s.data[3]), age = IntOrNullParse(s.data[4]), diet = IntOrNullParse(s.data[5]), location = IntOrNullParse(s.data[6]), demeanor = s.data[7], kidFriendly = BoolOrNullParse(s.data[8]), petFriendly = BoolOrNullParse(s.data[9]), gender = BoolOrNullParse(s.data[10]), adoptionStatus = s.data[11], Employee_ID = IntOrNullParse(s.data[12]) }); /* in this last select statement */ foreach (var animal in query) { var a = new Animal(); a.name = animal.name; a.breed = animal.breed; a.weight = animal.weight; a.age = animal.age; a.diet = animal.diet; a.location = animal.location; a.demeanor = animal.demeanor; a.kidFriendly = animal.kidFriendly; a.petFriendly = animal.petFriendly; a.gender = animal.gender; a.adoptionStatus = animal.adoptionStatus; a.Employee_ID = animal.Employee_ID; db.Animals.InsertOnSubmit(a); Console.WriteLine("saving..."); db.SubmitChanges(); //} } }
public static void UpdateAdoption(bool v, ClientAnimalJunction clientAnimalJunction) { HumaneSociety2DataContext db = new HumaneSociety2DataContext(); var animalAdopted = db.Animals.Where(c => c.ID == clientAnimalJunction.animal).First(); if (v == true) { animalAdopted.adoptionStatus = "adopted"; clientAnimalJunction.approvalStatus = "adopted"; } else if (v == false) { clientAnimalJunction.approvalStatus = "not adopted"; animalAdopted.adoptionStatus = "not adopted"; } db.SubmitChanges(); }
internal static void AddNewClient(string firstName, string lastName, string username, string password, string email, string streetAddress, int zipCode, int stateId) { Client newClient = new Client(); newClient.FirstName = firstName; newClient.LastName = lastName; newClient.UserName = username; newClient.Password = password; newClient.Email = email; Address addressFromDb = db.Addresses.Where(a => a.AddressLine1 == streetAddress && a.Zipcode == zipCode && a.USStateId == stateId).FirstOrDefault(); // if the address isn't found in the Db, create and insert it if (addressFromDb == null) { Address newAddress = new Address(); newAddress.AddressLine1 = streetAddress; newAddress.City = null; newAddress.USStateId = stateId; newAddress.Zipcode = zipCode; db.Addresses.InsertOnSubmit(newAddress); db.SubmitChanges(); addressFromDb = newAddress; } // attach AddressId to clientFromDb.AddressId newClient.AddressId = addressFromDb.AddressId; db.Clients.InsertOnSubmit(newClient); db.SubmitChanges(); }
public PopulateDB() { db.Employees.InsertOnSubmit(steveEmployee); db.SubmitChanges(); }