Beispiel #1
0
        public static void UpdateShot(string type, Animal animal)
        {
            var db   = new HumaneSocietyDataContext();
            var shot = db.Shots.Where(s => s.name == type).FirstOrDefault();

            if (shot == null)
            {
                AddNewShot(type);
                shot = db.Shots.Where(s => s.name == type).FirstOrDefault();
            }

            var animalShotJunction = db.AnimalShotJunctions.Where(a => a.Animal.ID == animal.ID && a.Shot.ID == shot.ID).FirstOrDefault();

            if (animalShotJunction == null)
            {
                animalShotJunction              = new AnimalShotJunction();
                animalShotJunction.Animal_ID    = animal.ID;
                animalShotJunction.Shot_ID      = shot.ID;
                animalShotJunction.dateRecieved = DateTime.Now;
                db.AnimalShotJunctions.InsertOnSubmit(animalShotJunction);
            }
            else
            {
                animalShotJunction.dateRecieved = DateTime.Now;
            }

            db.SubmitChanges();
        }
        internal static void UpdateShot(string v, Animal animal)
        {
            HumaneSocietyDataContext db           = new HumaneSocietyDataContext();
            Animal             animalUpdating     = db.Animals.Where(c => c.ID == animal.ID).First();
            Shot               shotUpdating       = db.Shots.Where(c => c.name == v).First();
            AnimalShotJunction animalShotJunction = db.AnimalShotJunctions.Where(c => c.Animal_ID == animalUpdating.ID).Where(c => c.Shot_ID == shotUpdating.ID).First();

            animalShotJunction.dateRecieved = DateTime.Now;
        }
Beispiel #3
0
        public static void UpdateShot(string typeOfShot, Animal animal)
        {
            HumaneSocietyDataContext db         = new HumaneSocietyDataContext();
            AnimalShotJunction       animalShot = new AnimalShotJunction();

            animalShot.Animal_ID    = animal.ID;
            animalShot.Shot_ID      = GetShotID(typeOfShot);
            animalShot.dateRecieved = DateTime.Now;
            db.AnimalShotJunctions.InsertOnSubmit(animalShot);
        }
Beispiel #4
0
        public static void AddShot(Shot shot, Animal animal)
        {
            HumaneSocietyDataContext database   = new HumaneSocietyDataContext();
            AnimalShotJunction       shotUpdate = new AnimalShotJunction();

            shotUpdate.Animal_ID    = animal.ID;
            shotUpdate.dateRecieved = DateTime.Now;
            shotUpdate.Shot_ID      = shot.ID;

            database.AnimalShotJunctions.InsertOnSubmit(shotUpdate);
            database.SubmitChanges();
        }
Beispiel #5
0
 public static void UpdateShot(string input, Animal animal)
 {
     using (HumaneSocietyDataContext context = new HumaneSocietyDataContext())
     {
         int shotID = GetShotType(input);
         AnimalShotJunction newShot = new AnimalShotJunction();
         newShot.Animal_ID    = animal.ID;
         newShot.Shot_ID      = shotID;
         newShot.dateRecieved = DateTime.Now;
         context.AnimalShotJunctions.InsertOnSubmit(newShot);
         context.SubmitChanges();
     }
 }
Beispiel #6
0
        public static void UpdateShot(string typeOfShot, Animal animal) //void
        {
            HumaneSocietyDataContext context = new HumaneSocietyDataContext();

            AnimalShotJunction animalShotJunction = new AnimalShotJunction();

            animalShotJunction.Animal_ID    = animal.ID;
            animalShotJunction.dateRecieved = DateTime.Now;
            animalShotJunction.Shot_ID      = GetShotID(typeOfShot);
            context.AnimalShotJunctions.InsertOnSubmit(animalShotJunction);

            try
            {
                context.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }