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 static void AddNewShot(string name) { var db = new HumanSocietyDataContext(); var shot = new Shot(); shot.Name = name; db.Shots.InsertOnSubmit(shot); db.SubmitChanges(); }
internal static void UpdateAdoption(bool isAdopted, Adoption adoption) { // Adoption.ApprovalStatus == "denied"; ? var db = new HumanSocietyDataContext(); Adoption adoptionResult = db.Adoptions.Where(c => c.AdoptionFee == adoption.AnimalId).First(); db.SubmitChanges(); }
internal static void UpdateAnimal(int animalId, Dictionary<int, string> updates) { var db = new HumanSocietyDataContext(); var newInfo = db.Animals.Where(n => n.AnimalId == animalId); foreach (var n in newInfo) { db.SubmitChanges(); } }
internal static Adoption Adopt(Animal animal, Client client) { var adoption = new Adoption(); var animal = new Animal(); var client = new Client(); Animal GetAnimalByIdPtr = new GetAnimalByIdPtr(GetAnimalById(); object inkvoke(); var db = new HumanSocietyDataContext(); db.Adoptions.InsertOnSubmit(adoption); db.SubmitChanges(); set { Adoption.ApprovalStatus == "Adopted" }; }
// TODO: Animal CRUD Operations internal static void AddAnimal(Animal animal) { HumanSocietyDataContext MyTable = new HumanSocietyDataContext(); MyTable.Animals.InsertOnSubmit(animal); MyTable.SubmitChanges(); }