Beispiel #1
0
        public Animal Create(CreateAnimalRequest newAnimal, Enclosure enclosure)
        {
            if (!_context.AnimalClasses.Any(v => v.AnimalClassification == newAnimal.AnimalClass))
            {
                AnimalClass animalClass = new AnimalClass()
                {
                    AnimalClassification = newAnimal.AnimalClass
                };

                _context.AnimalClasses.Add(animalClass);
                _context.SaveChanges();
            }
            // var enclosureId =
            //   enclosure = _context.Enclosures.GetByEnclosureName(newAnimal.EnclosureName);
            var newAnimalClass = GetAnimalClass(newAnimal.AnimalClass);
            var insertResponse = _context.Animals.Add(new Animal
            {
                AnimalName    = newAnimal.AnimalName,
                Species       = newAnimal.Species,
                Sex           = newAnimal.Sex,
                DateOfBirth   = newAnimal.DateOfBirth,
                DateAcquired  = newAnimal.DateAquired,
                AnimalClassId = newAnimalClass.AnimalClassId,
                EnclosureId   = enclosure.EnclosureId
            });

            _context.SaveChanges();

            return(insertResponse.Entity);
        }
Beispiel #2
0
        public AnimalTable(Panel pnl)
        {
            InitializeComponent();
            painel = pnl;
            DataTable dt = new AnimalClass().retAnimais();

            row = new AnimalRow[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                AnimalClass animal = new AnimalClass();
                animal.codAnimal          = dt.Rows[i]["codAnimal"].ToString();
                animal.Cliente_codCliente = dt.Rows[i]["Cliente_codCliente"].ToString();
                animal.nome          = dt.Rows[i]["nome"].ToString();
                animal.anoNascimento = dt.Rows[i]["anoNascimento"].ToString();
                animal.peso          = dt.Rows[i]["peso"].ToString();
                animal.grupo         = dt.Rows[i]["grupo"].ToString();
                animal.raca          = dt.Rows[i]["raca"].ToString();
                animal.genero        = dt.Rows[i]["genero"].ToString();
                animal.vacinacao     = dt.Rows[i]["vacinacao"].ToString();
                animal.comportamento = dt.Rows[i]["comportameto"].ToString();

                row[i]          = new AnimalRow(animal, pnl);
                row[i].TopLevel = false;
                row[i].Location = new Point(0, i * 32);
                pnlTable.Controls.Add(row[i]);
                row[i].Show();

                int index = i;
                row[i].MouseEnter += (sender, e) => mouseEnter(sender, e, index);
            }
        }
Beispiel #3
0
 private void LoadAttributes()
 {
     animalClass       = critterPed.Model.GetAnimalClass();
     animalName        = critterPed.Model.GetAnimalName();
     originalMaxHealth = critterPed.MaxHealth;
     originalRGroup    = critterPed.RelationshipGroup;
     strenth           = critterPed.Model.GetAnimalStrength();
 }
Beispiel #4
0
        private void click(object sender, EventArgs e, Panel pnl, AnimalClass animal)
        {
            AnimalEdit objEdit = new AnimalEdit(animal, pnl);

            pnl.Controls.Clear();
            objEdit.TopLevel = false;
            pnl.Controls.Add(objEdit);
            objEdit.Show();
        }
Beispiel #5
0
        /// <summary>
        /// Method returning set of available cages
        /// </summary>
        /// <param name="animalClass"></param>
        /// <returns></returns>
        public List <CageViewModel> GetCages(string animalClass)
        {
            // creating object of AnimalClass that name is equal to given animal class name
            AnimalClass animalClassOfAnimal = DbContext.AnimalClasses.SingleOrDefault(c => c.Name == animalClass);
            // creating list of cages available for chosen animal class
            List <Cage> cages = DbContext.Cages.Where(c => c.AnimalClassId == animalClassOfAnimal.Id).ToList();

            // returning created and mapped list
            return(Mapper.Map <List <Cage>, List <CageViewModel> >(cages));
        }
Beispiel #6
0
        public List <Animal> GetListOfAnimals(AnimalClass animalClass)
        {
            var animals = new List <Animal>();

            foreach (var aviary in _aviaries.FindAll(aviary => aviary.FreePlaces > 0))
            {
                foreach (var animal in aviary.GetListOfInhabitants()
                         .FindAll(inhabitant => inhabitant.GetType().Name.ToString() == animalClass.ToString()))
                {
                    animals.Add(animal);
                }
            }
            return(animals);
        }
 public AnimalEdit(AnimalClass animal, Panel pnl)
 {
     InitializeComponent();
     this.animal        = animal;
     codCliente.Text    = animal.Cliente_codCliente;
     nome.Text          = animal.nome;
     anoNasc.Text       = animal.anoNascimento;
     peso.Text          = animal.peso;
     grupo.Text         = animal.grupo;
     raca.Text          = animal.raca;
     genero.Text        = animal.genero;
     vacinacao.Checked  = animal.vacinacao == "True";
     comportamento.Text = animal.comportamento;
     painel             = pnl;
 }
Beispiel #8
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            AnimalClass animal = new AnimalClass();

            animal.codAnimal          = animal.retProxCodAnimal();
            animal.Cliente_codCliente = codCliente.Text;
            animal.nome          = nome.Text;
            animal.anoNascimento = anoNasc.Text;
            animal.peso          = peso.Text;
            animal.grupo         = grupo.Text;
            animal.raca          = raca.Text;
            animal.genero        = genero.Text;
            animal.vacinacao     = vacinacao.Checked?"1":"0";
            animal.comportamento = comportamento.Text;
            animal.inserirAnimal();
            sair();
        }
Beispiel #9
0
        /// <summary>
        /// Method to update animal data.
        /// </summary>
        /// <param name="newAnimalName"></param>
        /// <param name="newAnimalClass"></param>
        /// <param name="newCageNumber"></param>
        /// <param name="animalId"></param>
        public bool UpdateAnimal(string newAnimalName, string newAnimalClass, int newCageNumber, int animalId)
        {
            //finding object to update
            Animal animal = DbContext.Animals.SingleOrDefault(a => a.Id == animalId);
            // creating object of AnimalClass that name is equal to animalClass
            AnimalClass animalClassOfAnimal = DbContext.AnimalClasses.SingleOrDefault(c => c.Name == newAnimalClass);

            // checking if animalClassOfAnimal is null and returning false if it is
            if (animalClassOfAnimal == null)
            {
                return(false);
            }
            //changing object properties
            animal.Name        = newAnimalName;
            animal.CageId      = newCageNumber;
            animal.AnimalClass = animalClassOfAnimal;
            // saving changes
            return(DbContext.SaveChanges() > 0);
        }
Beispiel #10
0
        public static void Initialize(ModelBuilder modelBuilder)
        {
            var owls = new AnimalClass()
            {
                Id      = 1,
                Class   = "Bird",
                Family  = "Strigiformes",
                Species = "owl",
            };

            var john = new Employee()
            {
                Id        = 1,
                FirstName = "John",
                LastName  = "Silver",
                Age       = 34,
                Sex       = Sex.Male
            };

            var phil = new Animal()
            {
                Id          = 1,
                Name        = "Phil",
                Age         = 3,
                Sex         = Sex.Male,
                ClassId     = 1,
                CaretakerId = 1
            };

            var lona = new Animal()
            {
                Id          = 2,
                Name        = "Lona",
                Age         = 3,
                Sex         = Sex.Female,
                ClassId     = 1,
                CaretakerId = 1
            };

            modelBuilder.Entity <AnimalClass>().HasData(owls);
            modelBuilder.Entity <Employee>().HasData(john);
            modelBuilder.Entity <Animal>().HasData(phil, lona);
        }
        public async Task AddAsync(
            string name,
            int age,
            string imageUrl,
            AnimalClass animalClass,
            string userId)
        {
            var animal = new Animal
            {
                Name        = name,
                Age         = age,
                ImageUrl    = imageUrl,
                AnimalClass = animalClass,
                UserId      = userId
            };

            await this.db.AddAsync(animal);

            await this.db.SaveChangesAsync();
        }
Beispiel #12
0
    // Start is called before the first frame update
    void Start()
    {
        dataTracker          = FindObjectOfType <DataTracker>();
        cam                  = FindObjectOfType <Camera>();
        board                = FindObjectOfType <Board>();
        powerLevel           = .01f;
        healthBar.fillAmount = .01f;
        characterData        = SaveSystem.LoadCharacterData();
        classOfAnimal        = classesOfAnimals[characterData.currentCharacter].GetComponent <AnimalClass>();
        characterLevel       = characterData.levels[characterData.currentCharacter];
        icon.sprite          = classOfAnimal.ReturnSprite();
        animalImage.sprite   = classesOfAnimalImages[characterData.currentCharacter];
        isLeft               = true;
        Vector3 tempVector = Camera.main.ScreenToWorldPoint(icon.transform.position);

        tempVector   = new Vector3(tempVector.x, tempVector.y + 1.03f, 0);
        currentAlert = Instantiate(alertIcon, tempVector, Quaternion.identity);
        currentAlert.GetComponent <ParticleSystem>().Pause();
        currentAlert.SetActive(false);
    }
Beispiel #13
0
        public AnimalRow(AnimalClass animal, Panel pnl)
        {
            InitializeComponent();
            codAnimal.Text          = animal.codAnimal;
            Cliente_codCliente.Text = animal.Cliente_codCliente;
            nome.Text          = animal.nome;
            dataNasc.Text      = animal.anoNascimento;
            peso.Text          = animal.peso;
            grupo.Text         = animal.grupo;
            raca.Text          = animal.raca;
            genero.Text        = animal.genero;
            vacinacao.Text     = animal.vacinacao == "True"?"Sim":"Não";
            comportamento.Text = animal.comportamento;

            codAnimal.Click          += (sender, e) => click(sender, e, pnl, animal);
            Cliente_codCliente.Click += (sender, e) => click(sender, e, pnl, animal);
            dataNasc.Click           += (sender, e) => click(sender, e, pnl, animal);
            nome.Click += (sender, e) => click(sender, e, pnl, animal);
            this.Click += (sender, e) => click(sender, e, pnl, animal);
        }
Beispiel #14
0
        /// <summary>
        /// Method to create animal.
        /// </summary>
        /// <param name="animalName"></param>
        /// <param name="animalClass"></param>
        /// <param name="cageNumber"></param>
        public bool CreateAnimal(string animalName, string animalClass, int cageNumber)
        {
            //creating object of AnimalClass that name is equal to animalClass
            AnimalClass animalClassOfAnimal = DbContext.AnimalClasses.SingleOrDefault(c => c.Name == animalClass);

            // checking if animalClassOfAnimal is null and returning false if it is
            if (animalClassOfAnimal == null)
            {
                return(false);
            }
            // adding new Animal with given data
            DbContext.Animals.Add(new Animal()
            {
                Name        = animalName,
                AnimalClass = animalClassOfAnimal,
                CageId      = cageNumber
            });
            // saving changes
            return(DbContext.SaveChanges() > 0);
        }
Beispiel #15
0
    void Start()
    {
        s = SaveFile.Load("save.xml");

        camera = GameObject.Find("Main Camera");

        var ac = new AnimalClass("Lion");

        ac.Move(movementSpeed);
        ac.Jump(jumpSpeed);
        GameObject acgo = ac.GetPlayer();

        Animals.Add(acgo);

        var leemur = new AnimalClass("Leemur");

        //leemur.Move(movementSpeed);
        leemur.Jump(jumpSpeed);
        GameObject leemurthing = leemur.GetPlayer();

        Animals.Add(leemurthing);

        var cc = new AnimalClass("Cube");

        cc.Move(movementSpeed);
        cc.Jump(jumpSpeed);
        GameObject ccgo = cc.GetPlayer();

        Animals.Add(ccgo);


        acgo.SetActive(false);
        leemurthing.SetActive(false);

        currentAnimal = ccgo;

        //GameObject.Find("HUD").transform.SetParent(Player.transform);
    }
        public async Task EditAsync(
            int id,
            string name,
            int age,
            AnimalClass animalClass,
            string imageUrl)
        {
            var animal = await this.db
                         .Animals
                         .FirstOrDefaultAsync(a => a.Id == id);

            if (animal == null)
            {
                throw new InvalidOperationException();
            }

            animal.Name        = name;
            animal.Age         = age;
            animal.ImageUrl    = imageUrl;
            animal.AnimalClass = animalClass;

            await this.db.SaveChangesAsync();
        }
Beispiel #17
0
 public Species(string name, AnimalClass animalClass, ConsumeType consumeType)
 {
     SetName(name);
     AnimalClass = animalClass;
     ConsumeType = consumeType;
 }
Beispiel #18
0
 public List <Animal> FilterByClass(IEnumerable <Animal> animals, AnimalClass animalClass) =>
 animals.Where(o => o.Class == animalClass).ToList();
 public IAnimalOrderAndTypeSpecification(AnimalClass animalClass, AnimalOrder animalOrder)
 {
     _animalClass = animalClass;
     _animalOrder = animalOrder;
 }
Beispiel #20
0
 private void LoadAttributes()
 {
     animalClass = critterPed.Model.GetAnimalClass();
     animalName = critterPed.Model.GetAnimalName();
     originalMaxHealth = critterPed.MaxHealth;
     originalRGroup = critterPed.RelationshipGroup;
     strenth = critterPed.Model.GetAnimalStrength();
 }
Beispiel #21
0
 public void Update(AnimalClass item)
 {
     _dataBase.Entry(item).State = EntityState.Modified;
 }
 public AnimalClassListElement(AnimalClass animalClass)
 {
     _class = animalClass;
 }
Beispiel #23
0
 public void Create(AnimalClass item)
 {
     _dataBase.AnimalClasses.Add(item);
 }
 public AnimalClassSpecification(AnimalClass @animalClass)
 {
     _animalClass = @animalClass;
 }
 public AnimalClassAndOrderSpecification(AnimalClass @animalClass, AnimalOrder @animalOrder)
 {
     _animalClass = @animalClass;
     _animalOrder = @animalOrder;
 }
 public List <IAnimal> FilterByClass(IEnumerable <IAnimal> animals, AnimalClass animalClass)
 {
     return(animals.Where(o => o.Class.Equals(animalClass)).ToList());
 }
 public AnimalClassSpecification(AnimalClass animalClass)
 {
     _class = animalClass;
 }