Exemple #1
0
        internal static void RemoveAdoption(int animalId, int clientId)
        {
            Adoption adoption = db.Adoptions.Where(a => a.AnimalId == a.AnimalId && a.ClientId == a.ClientId).FirstOrDefault();

            db.Adoptions.DeleteOnSubmit(adoption);
            db.SubmitChanges();
        }
        internal static void UpdateAdoption(bool isAdopted, Adoption adoption)
        {
            try
            {
                Adoption adoption1 = db.Adoptions.Where(x => x.AnimalId == adoption.AnimalId).FirstOrDefault();

                if (isAdopted)
                {
                    adoption1.ApprovalStatus   = "Approved";
                    adoption1.PaymentCollected = true;
                }
                else
                {
                    adoption1.ApprovalStatus = "Denied";
                }
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine(e);
            }



            try
            {
                db.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #3
0
        internal static void UpdateAdoption(bool v, Adoption adoption)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();
            Animal animal = new Animal();

            adoption = db.Adoptions.Where(a => a.AnimalId == adoption.AnimalId).FirstOrDefault();
            animal   = db.Animals.Where(a => a.AnimalId == adoption.AnimalId).FirstOrDefault();
            if (v)
            {
                adoption.ApprovalStatus = "Adopted";
                animal.AdoptionStatus   = "Adopted";
            }
            else
            {
                db.Adoptions.DeleteOnSubmit(adoption);
                animal.AdoptionStatus = "Not Adopted";
            }
            try
            {
                db.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #4
0
        // TODO: Adoption CRUD Operations
        internal static void Adopt(Animal animal, Client client)
        {
            //combine client and animal
            //use animal and client passed in to create new table


            //ATTRIBUTES OF ADOPT:
            //ClientId
            //AnimalId
            //ApprovalStatus
            //AdoptionFee (75)
            //PaymentCollected

            Adoption adoption = new Adoption();

            adoption.ClientId       = client.ClientId;
            adoption.AnimalId       = animal.AnimalId;
            adoption.ApprovalStatus = "Pending";
            adoption.AdoptionFee    = 75;
            //after mvp comeback and fix hardcode

            if (UserInterface.GetBitData($"The adoption cost is {adoption.AdoptionFee}! Would you like to pay right now? \n" +
                                         $"Type yes or no: "))
            {
                adoption.PaymentCollected = true;
            }
            else
            {
                adoption.PaymentCollected = false;
            }

            db.Adoptions.InsertOnSubmit(adoption);
            db.SubmitChanges();
        }
Exemple #5
0
        internal static void RemoveAdoption(int animalId, int clientId)
        {
            Adoption searchAdoption = db.Adoptions.Where(a => a.AnimalId == animalId && a.ClientId == clientId).Single();

            db.Adoptions.DeleteOnSubmit(searchAdoption);
            db.SubmitChanges();
        }
        internal static void UpdateAdoption(bool isAdopted, Adoption adoption)
        {
            //Search DB for this particular adoption
            Adoption adoptionFromDb = null;

            try
            {
                adoptionFromDb = db.Adoptions.Where(c => c.AnimalId == adoption.AnimalId).Single();
            }
            catch (InvalidOperationException)
            {
                UserInterface.DisplayMessage("No adoption matches the ID passed in.");
                UserInterface.DisplayMessage("No updates have been made.");
                return;
            }
            Animal animalFromDb = db.Animals.Where(c => c.AnimalId == adoption.AnimalId).Single();

            if (isAdopted)
            {
                ApproveAdoption(adoptionFromDb, animalFromDb);
            }
            else
            {
                RemoveAdoption(adoptionFromDb);
            }
            db.SubmitChanges();
        }
        internal static IQueryable <Adoption> GetPendingAdoptions()
        {
            Adoption adoption = new Adoption();

            adoption = db.Adoptions.Where(a => a.adoptionStatus == "Adoption pending");
            return(adoption);
        }
Exemple #8
0
 // Adoption CRUD Operations
 internal static void Adopt(Animal animal, Client client)
 {
     if (animal.AdoptionStatus == "available" || animal.AdoptionStatus == "pending")
     {
         Adoption adopt = new Adoption();
         adopt.AnimalId         = animal.AnimalId;
         adopt.ClientId         = client.ClientId;
         adopt.ApprovalStatus   = "pending";
         adopt.PaymentCollected = true;
         db.Adoptions.InsertOnSubmit(adopt);
         try
         {
             db.SubmitChanges();
         }
         catch
         {
             Console.WriteLine("You have already applied to adopt " + animal.Name);
             Console.ReadLine();
         }
     }
     else
     {
         Console.WriteLine(animal.Name + " is not available for adoption.");
         Console.ReadLine();
     }
 }
Exemple #9
0
        internal static void UpdateAdoption(bool isAdopted, Adoption adoption)
        {
            if (isAdopted)
            {
                adoption.ApprovalStatus = "Adopted";
                if (!(bool)adoption.PaymentCollected)
                {
                    UserInterface.DisplayUserOptions($"Your adoption was approved! The adoption cost is {adoption.AdoptionFee}!");
                    adoption.PaymentCollected = true;
                }
                else
                {
                    UserInterface.DisplayUserOptions("Your adoption was approved! Have a nice day!");
                }
            }
            else if (!isAdopted)
            {
                adoption.ApprovalStatus = "Adoption Declined";
                if ((bool)adoption.PaymentCollected)
                {
                    UserInterface.DisplayUserOptions("Your adoption was declined! Your adoption fee will be returned to you!");
                    adoption.PaymentCollected = false;
                }
                else
                {
                    UserInterface.DisplayUserOptions("Your adoption was declined! Sorry have a nice day!");
                }
            }

            db.SubmitChanges();
        }
Exemple #10
0
 internal static void UpdateAdoption(bool isAdopted, Adoption adoption)
 {
     if (isAdopted)
     {
         adoption.ApprovalStatus = "Approved";
         RemoveAdoption(adoption.AnimalId, adoption.ClientId, adoption);
     }
 }
        internal static void RemoveAdoption(int animalId, int clientId)
        {
            Adoption pendingAdoption = new Adoption();

            pendingAdoption = db.Adoptions.Where(a => a.AnimalId == animalId).Where(c => c.ClientId == clientId).First();
            db.Adoptions.DeleteOnSubmit(pendingAdoption);
            db.SubmitChanges();
        }
Exemple #12
0
        internal static void Adopt(IQueryable <Animal> animal, Client client) // Needs To check
        {
            Adoption NewAnimalToAdopt = new Adoption();

            NewAnimalToAdopt.AnimalId = client.ClientId;
            database.Adoptions.InsertOnSubmit(NewAnimalToAdopt);
            database.SubmitChanges();
        }
        internal static void RemoveAdoption(int animalId, int clientId)
        {
            Adoption adoptionToBeDeleted = null;

            adoptionToBeDeleted = db.Adoptions.Where(i => i.AnimalId == animalId && i.ClientId == clientId).FirstOrDefault();
            db.Adoptions.DeleteOnSubmit(adoptionToBeDeleted);
            db.SubmitChanges();
        }
Exemple #14
0
        internal static void UpdatePaymentStatus(Adoption adoption)
        {
            HumaneSocietyDataContext DB = new HumaneSocietyDataContext();

            adoption.PaymentCollected = true;
            adoption.AdoptionFee      = 75;
            DB.SubmitChanges();
        }
Exemple #15
0
        internal static void RemoveAdoption(int animalId, int clientId)//_stilltodo_______________________________________________/^\
        {
            Adoption adoption = db.Adoptions.Where(a => a.AnimalId == animalId && a.ClientId == clientId).Single();

            db.Adoptions.DeleteOnSubmit(adoption);
            db.SubmitChanges();
            //throw new NotImplementedException();
        }
Exemple #16
0
        internal static void UpdateAdoption(bool approve, Adoption adoption)
        {
            HumaneSocietyDataContext db = new HumaneSocietyDataContext();

            db.Adoptions.Where(a => a.AdoptionId == adoption.AdoptionId).First().ApprovalStatus = approve ? "approved" : "denied";
            db.Animals.Where(a => a.AnimalId == adoption.AnimalId).First().AdoptionStatus       = approve ? "approved" : "denied";
            db.SubmitChanges();
        }
        internal static void UpdateAdoption(bool isAdopted, Adoption adoption)
        {
            adoption = db.Adoptions.FirstOrDefault(a => a.AnimalId == adoption.AnimalId && a.ApprovalStatus == adoption.ApprovalStatus);
            adoption.ApprovalStatus = (isAdopted == true) ? "Approved" : "Denied";
            Animal foundAnimal = db.Animals.FirstOrDefault(a => a.AnimalId == adoption.AnimalId);

            foundAnimal.AdoptionStatus = "Adopted";
            db.SubmitChanges();
        }
Exemple #18
0
        // TODO: Adoption CRUD Operations
        internal static void Adopt(Animal animal, Client client)
        {
            Adoption adoption = new Adoption {
                ClientId = client.ClientId, AnimalId = animal.AnimalId, ApprovalStatus = "Pending", AdoptionFee = 75, PaymentCollected = false
            };

            db.Adoptions.InsertOnSubmit(adoption);
            db.SubmitChanges();
        }
Exemple #19
0
 internal static void UpdateAdoption(bool isAdopted, Adoption adoption)
 {
     if (isAdopted == true)
     {
         adoption.ApprovalStatus   = "Accepted";
         adoption.PaymentCollected = true;
     }
     db.SubmitChanges();
 }
Exemple #20
0
        internal static void RemoveAdoption(int animalId, int clientId) //NEED TO TEST **Mike said it does not need to be called!
        {
            //Need to use clientID?

            Adoption animal = db.Adoptions.Where(a => a.AnimalId == animalId).Single();

            db.Adoptions.DeleteOnSubmit(animal);
            db.SubmitChanges();
        }
Exemple #21
0
        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();

        }
Exemple #22
0
        public static void Adopt(Animal animal, Client client)
        {
            Adoption newAdoption = new Adoption();

            newAdoption.ClientId    = client.ClientId;
            newAdoption.AnimalId    = animal.AnimalId;
            newAdoption.AdoptionFee = 200;
            context.Adoptions.InsertOnSubmit(newAdoption);
            context.SubmitChanges();
        }
        // TODO: Adoption CRUD Operations
        internal static void Adopt(Animal animal, Client client)
        {
            Adoption adoption = new Adoption();

            adoption.AnimalId       = animal.AnimalId;
            adoption.ClientId       = client.ClientId;
            adoption.ApprovalStatus = "Pending";
            db.Adoptions.InsertOnSubmit(adoption);
            db.SubmitChanges();
        }
Exemple #24
0
 internal static void UpdateAdoption(bool isAdopted, Adoption adoption)
 {
     if (isAdopted == true)
     {
         Adoption adoptionUpdate = db.Adoptions.Where(a => a.AnimalId == adoption.AnimalId && a.ClientId == adoption.ClientId).Select(a => a).Single();
         adoptionUpdate.ApprovalStatus   = "Approved";
         adoptionUpdate.PaymentCollected = true;
         db.SubmitChanges();
     }
 }
Exemple #25
0
        internal static void Adopt(object animal, Client client)
        {
            HumaneSocietyDataContext DB = new HumaneSocietyDataContext();
            Animal   animals            = null;
            Adoption adoption           = null;
            var      adopts             = DB.Adoptions.Where(a => a.AdoptionId == adoption.AdoptionId && a.ClientId == client.ClientId && a.AnimalId == animals.AnimalId).FirstOrDefault();
            var      status             = DB.Adoptions.Where(s => s.ApprovalStatus == adoption.ApprovalStatus && s.AdoptionFee == adoption.AdoptionFee && s.PaymentCollected == adoption.PaymentCollected).FirstOrDefault();

            return;
        }
Exemple #26
0
        // TODO: Adoption CRUD Operations
        internal static void Adopt(Animal animal, Client client)
        {
            Adoption adoption = new Adoption();

            adoption.AnimalId         = animal.AnimalId;
            adoption.ClientId         = client.ClientId;
            adoption.ApprovalStatus   = "currently pending";
            adoption.AdoptionFee      = 25;
            adoption.PaymentCollected = false;
        }
Exemple #27
0
        internal static void UpdateAdoption(bool v, Adoption adoption)
        {
            var thisAdoption = db.Adoptions.Where(a => a.AdoptionId == adoption.AdoptionId).FirstOrDefault();

            if (v)
            {
                adoption.ApprovalStatus = "approved";
            }
            TryDBChanges();
        }
Exemple #28
0
        internal static void RemoveAdoption(int animalId, int clientId)
        {
            Animal animal = db.Animals.Where(a => a.AnimalId == animalId).Single();

            animal.AdoptionStatus = "not adopted";
            Adoption adoption = db.Adoptions.Where(a => a.AnimalId == animalId && a.ClientId == clientId).SingleOrDefault();

            db.Adoptions.DeleteOnSubmit(adoption);
            db.SubmitChanges();
        }
        // TODO: Adoption CRUD Operations
        internal static void Adopt(Animal animal, Client client)
        {
            Adoption adoption = new Adoption();

            adoption.ClientId         = client.ClientId;
            adoption.AnimalId         = animal.AnimalId;
            adoption.PaymentCollected = true;
            db.Adoptions.InsertOnSubmit(adoption);
            db.SubmitChanges();
        }
Exemple #30
0
        internal static void RemoveAdoption(Adoption adoptionRemove)
        {
            Animal animal = null;

            try
            {
            }
            catch (InvalidOperationException f)
            {
            }
        }