コード例 #1
0
        //
        // GET: /Turma/Delete/5

        public ActionResult Delete(int id)
        {
            AnimalModel animal = GerenciadorAnimal.GetInstance().Obter(id);

            ViewBag.Error = "";
            return(View(animal));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,ProprietarioId,EspecieId,Peso,Altura,Comprimento,Pedigree")] AnimalModel animalModel)
        {
            if (id != animalModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    animalModel.Nome = animalModel.Nome.ToUpper();
                    _context.Update(animalModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimalModelExists(animalModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EspecieId"]      = new SelectList(_context.EspecieModel, "Id", "Nome", animalModel.EspecieId);
            ViewData["ProprietarioId"] = new SelectList(_context.ProprietarioModel, "Id", "Nome", animalModel.ProprietarioId);
            return(View(animalModel));
        }
コード例 #3
0
 public BasicInfoViewModel(int animalID)
 {
     Animal = new AnimalModel();
     Animal.GetAnimal(animalID);
     Image = new ImageModel();
     Image.GetImage(Animal.ImagePath);
 }
コード例 #4
0
        public AnimalModel AddAnimal(AnimalModel animalModel)
        {
            var animal = AnimalMapper(animalModel);

            _repo.AddAnimal(animal);
            return(animalModel);
        }
コード例 #5
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Access data test");
            IPersonModel person = new PersonModel {
                FirstName = "Jhon", LastName = "Smith", Gender = "M"
            };
            IAnimalModel animal = new AnimalModel {
                Name = "Milu", Species = "Cat", Race = "Any"
            };

            IDataAccess <IPersonModel> personData = new DataAccessSqlServer <IPersonModel>();

            personData.Create(person);

            IDataAccess <IAnimalModel> animalData = new DataAccessSqlServer <IAnimalModel>();

            animalData.Create(animal);

            //IDataAccess<Utilities> utilitiesData = new DataAccessSqlServer<Utilities>();

            /*var tmp = new NullableStruct<bool>();
             * Console.WriteLine($"Ha value ? {tmp.HasValue}");
             * Console.WriteLine($"Value: {tmp.GetValueOrDefault()}");*/

            Console.ReadLine();
        }
コード例 #6
0
        private void OnTrackingFound()
        {
            Renderer[] rendererComponents = GetComponentsInChildren <Renderer>(true);
            Collider[] colliderComponents = GetComponentsInChildren <Collider>(true);

            // Enable rendering:
            foreach (Renderer component in rendererComponents)
            {
                component.enabled = true;
            }

            // Enable colliders:
            foreach (Collider component in colliderComponents)
            {
                component.enabled = true;
            }

            // Enable AnimalModel
            AnimalModel animal = GetComponentInChildren <AnimalModel>(true);

            if (animal != null)
            {
                animal.OnAnimalAppear();
            }
            else
            {
                Debug.LogError("OnTrackingFound: Can NOT find AnimalModel in child!!!");
            }

            Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
        }
コード例 #7
0
        public AnimalModels GetAll()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            AnimalModels animal = new AnimalModels();

            animal.Info = new List <AnimalModel>();

            var webClient = new WebClient();
            var html      = webClient.DownloadString("https://a-z-animals.com/animals/pictures/");

            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(html);

            var nodes = htmlDocument
                        .DocumentNode
                        .Descendants("img")
                        .Where(node =>
                               node.Attributes["src"] != null &&
                               node.Attributes["title"] != null)
                        .ToList();

            foreach (var node in nodes)
            {
                AnimalModel item = new AnimalModel();
                item.AnimalName = node.Attributes["title"].Value;
                item.Src        = node.Attributes["src"].Value;
                animal.Info.Add(item);
            }
            return(animal);
        }
コード例 #8
0
        public List <AnimalModel> GetAllAnimals()
        {
            List <AnimalModel> AllAnimals = new List <AnimalModel>();
            string             query      = $"Select * from Animals";

            SqlParameter[] parameters = { };

            IEnumerable <IDataRecord> reader = CreateReader(query, parameters);

            foreach (IDataRecord record in reader)
            {
                AnimalModel temp = new AnimalModel()
                {
                    name     = record["Name"].ToString(),
                    age      = (int)record["Age"],
                    weight   = (int)record["Weight"],
                    gender   = (AnimalModel.Genders)Enum.Parse(typeof(AnimalModel.Genders), record["Gender"].ToString()),
                    species  = (AnimalModel.Species)Enum.Parse(typeof(AnimalModel.Species), record["Species"].ToString()),
                    image    = record["Image"].ToString(),
                    cage     = (int)record["Cage"],
                    price    = (float)(double)record["Price"], //<- Blame microsoft
                    reserved = (bool)record["Reserved"],
                    breed    = record["Breed"].ToString(),
                    about    = record["About"].ToString()
                };
                temp.characteristics = GetCharacteristicsFromAnimal(temp);
                AllAnimals.Add(temp);
            }
            return(AllAnimals);
        }
コード例 #9
0
 public AddAnimalViewModel(HomeViewModel parent)
 {
     prnt1  = parent;
     Image  = new ImageModel();
     Animal = new AnimalModel();
     Stay   = new StayModel();
 }
コード例 #10
0
        public AnimalModel UpdateAnimal(AnimalModel animalModel)
        {
            var animal = AnimalMapper(animalModel);

            _repo.UpdateAnimal(animal);
            return(animalModel);
        }
コード例 #11
0
ファイル: AnimalCad.aspx.cs プロジェクト: vinnyfmc/PortalSCV
        private void DetalharObj(int Id)
        {
            AnimalModel        oModel     = new AnimalModel();
            List <AnimalModel> oListModel = new List <AnimalModel>();
            AnimalNegocios     oNegocios  = new AnimalNegocios();

            oModel.Codigo = Id;
            oListModel    = oNegocios.Listar(oModel);
            if (oListModel.Count > 0)
            {
                oModel = oListModel[0];

                Animal_Id.Value = oModel.Codigo.ToString();

                ddlCliente.SelectedValue = oModel.Codigo_Cliente.ToString();

                txtNome.Text          = oModel.Nome;
                txtRaca.Text          = oModel.Raca;
                txtCor.Text           = oModel.Cor;
                txtIdade.Text         = oModel.Idade.ToString();
                txtPeso.Text          = oModel.Peso.ToString();
                ddlSexo.SelectedValue = oModel.Sexo.ToString();
                txtObs.Text           = oModel.DescricaoDoencas;

                CodigoFunc.Value = oModel.Codigo_Funcionario.Value.ToString();

                if (oModel.DataNascimento != null)
                {
                    txtDataNascimento.Text = ((DateTime)oModel.DataNascimento).ToString("dd/MM/yyyy");
                }

                cbStatus.SelectedValue = ((bool)oModel.Ativo).ToString();
            }
        }
コード例 #12
0
        public ActionResult CreateUpdateAnimal(AnimalModel animalModel)
        {
            if (!ModelState.IsValid)
            {
                return(ShowErrorMessage(GetModelErrors(ModelState)));
            }

            if (!CheckEmployeeHasBalance(animalModel.Price))
            {
                return(ShowErrorMessage(Constant.InsufficientBalance));
            }

            var animal = new Animal();

            if (animalModel.Id > 0)
            {
                animal = FarmManagementEntities.Animals.Single(x => x.Id == animalModel.Id);
            }

            animal.FarmId    = animalModel.FarmId;
            animal.VendorId  = animalModel.VendorId;
            animal.AccountId = animalModel.AccountId;

            animal.AnimalName   = animalModel.AnimalName;
            animal.PurchaseDate = Convert.ToDateTime(animalModel.PurchaseDate);
            animal.Age          = animalModel.Age;
            animal.Color        = animalModel.Color;
            animal.Description  = animalModel.Description;
            animal.FamilyName   = animalModel.FamilyName;

            animal.Category = animalModel.AnimalCategory.ToNullIfEmptyEnum <AnimalCategory>();
            animal.Sex      = animalModel.AnimalGender.ToNullIfEmptyEnum <Gender>();

            var fileUpload = ClientSession.FileUploads.Single(x => x.FileUploadGuid == animalModel.AnimalGuid && x.FileUploadName == FileUploadPath.Animal && !x.HasRemoved);

            animal.Photo = System.IO.Path.GetFileName(fileUpload.FilePath);

            if (animalModel.Id == 0)
            {
                animal.Price      = animalModel.Price;
                animal.InsertDate = DateTime.Now;
                animal.UserId     = animalModel.UserId;
                FarmManagementEntities.Animals.Add(animal);

                ManageEmployeeBalance(animalModel.Price);
            }
            else
            {
                animal.UpdateDate = DateTime.Now;
            }

            FarmManagementEntities.SaveChanges();

            UpdateFileUploadPath(FileUploadPath.Animal, fileUpload, animal.Id);
            ClearAllFileUpload();

            var message = string.Format(Constant.SuccessMessage, animalModel.Id > 0 ? "updated" : "added");

            return(ShowSuccessMessage(message));
        }
コード例 #13
0
    public int checkOnAnimal(Vector3 position, int cardIdx)
    {
        int animalIndex = ConstEnums.NOT_ON_Animal;

        Evolution.ConstEnums.Skills cardType = playerMod.cardMods[cardIdx].cardType;

        foreach (GameObject animal in playerView.animals)
        {
            Vector3 animalSize   = animal.GetComponent <Collider> ().bounds.size;
            Vector3 animalCenter = animal.transform.position;

            float left   = animalCenter.x - animalSize.x / 2;
            float right  = animalCenter.x + animalSize.x / 2;
            float top    = animalCenter.z + animalSize.z / 2;
            float bottom = animalCenter.z - animalSize.z / 2;

            if (position.x < right && position.x > left)
            {
                if (position.z < top && position.z > bottom)
                {
                    AnimalModel mod = (AnimalModel)animal.GetComponent <AnimalView>().mod;
                    if (!mod.property.getSkill(cardType))
                    {
                        animalIndex = mod.index;
                    }
                    else
                    {
                        animalIndex = ConstEnums.ANIMAL_HAS_SKILL;
                    }
                    break;
                }
            }
        }
        return(animalIndex);
    }
コード例 #14
0
        public AnimalModel[] GetGrid()
        {
            var total = this.GetLives();

            AnimalModel[] animals = new AnimalModel[total];

            int i = 0;

            for (int x = 0; x < this.grid.GetLength(0); x += 1)
            {
                for (int y = 0; y < this.grid.GetLength(1); y += 1)
                {
                    var animal = this.grid[x, y];

                    if (animal != null && animal.live)
                    {
                        animals[i++] = new AnimalModel
                        {
                            specie   = animal.specie,
                            x        = x * 100,
                            y        = y * 50,
                            calorias = animal.calorias
                        };
                    }
                }
            }

            return(animals);
        }
コード例 #15
0
        // GET: Parrain/Home
        public ActionResult Index()
        {
            ViewBag.title = "Area Parrain - Marraine";
            ParrainModel          parainM = new ParrainModel(); // donc contient :  IsConnected + package
            UtilisateurRepository ur      = new UtilisateurRepository(ConfigurationManager.ConnectionStrings["My_Asptest_Cnstr"].ConnectionString);

            // 1.
            parainM.Utilisateur = mapToVIEWmodels.utilisateurTOprofileModel(ur.getOne(SessionUtilisateur.ConnectedUser.IdUtilisateur));
            // 2.
            if (SessionUtilisateur.ConnectedUserPackage != null)
            {
                FormuleRepository fr = new FormuleRepository(ConfigurationManager.ConnectionStrings["My_Asptest_Cnstr"].ConnectionString);
                parainM.ThePackage = mapToVIEWmodels.formuleToFormuleModel(fr.getOne(SessionUtilisateur.ConnectedUserPackage.IdFormule));
            }
            // 3.
            if (SessionUtilisateur.ConnectedUserAnimals != null)
            {
                AnimalRepository ar = new AnimalRepository(ConfigurationManager.ConnectionStrings["My_Asptest_Cnstr"].ConnectionString);
                foreach (AnimalModel item in SessionUtilisateur.ConnectedUserAnimals)
                {
                    AnimalModel AnimalfromDB = mapToVIEWmodels.animalToAnimalModel(ar.getOne(item.IdAnimal));
                    parainM.AnimauxAdoptes.ToList().Add(AnimalfromDB);
                }
            }

            return(View(parainM));
        }
コード例 #16
0
 public AddAnimalViewModel(SearchAnimalViewModel parent)
 {
     prnt   = parent;
     Image  = new ImageModel();
     Animal = new AnimalModel();
     Stay   = new StayModel();
 }
コード例 #17
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Origem,NumeroCobertura,NomeAnimal,DataNascimento,Sexo,Desmamado,Pelagem,Categoria,Peso")] AnimalModel animalModel)
        {
            if (id != animalModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(animalModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimalModelExists(animalModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(animalModel));
        }
コード例 #18
0
        private ObservableCollection <AnimalModel> LoadFromXML()
        {
            state.ErrorState = string.Empty;
            ObservableCollection <AnimalModel> animals = new ObservableCollection <AnimalModel>();

            try
            {
                string dirname = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                string fname   = dirname + "\\AnimalsData.xml";

                XDocument doc    = XDocument.Load(fname);
                var       anlist = from r in doc.Descendants("Animal")
                                   select new
                {
                    Name     = r.Element("Name").Value,
                    ImageLoc = r.Element("Imgloc").Value,
                    Color    = r.Element("Color").Value,
                    Sound    = r.Element("Sound").Value,
                    Feature  = r.Element("Feature").Value,
                };

                foreach (var r in anlist)
                {
                    AnimalModel am = new AnimalModel(r.Name, r.ImageLoc, r.Color, r.Sound, r.Feature);
                    animals.Add(am);
                }
            }
            catch (Exception ex)
            {
                state.ErrorState = "Error occured - " + ex.Message;
            }
            return(animals);
        }
コード例 #19
0
        public ActionResult DeleteConfirmed(int id)
        {
            AnimalModel animalModel = db.AnimalModels.Find(id);

            db.AnimalModels.Remove(animalModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #20
0
ファイル: AnimalService.cs プロジェクト: evilsquirr3l/trpz
        public void CreateAnimal(AnimalModel animalModel)
        {
            var animal = _mapper.Map <Animal>(animalModel);

            _unit.AnimalRepository.Create(animal);

            _unit.Save();
        }
コード例 #21
0
ファイル: AnimalService.cs プロジェクト: evilsquirr3l/trpz
        private int CalculateAssimilationHours(AnimalModel animal, FoodModel food)
        {
            var caloriesPerHour = animal.Weight * (_timeService.CurrentTime - animal.BirthDate).Days;

            var hoursFed = food.Calorific * food.AssimilationMultiplierCoefficient / caloriesPerHour;

            return(hoursFed);
        }
コード例 #22
0
        /// <summary>
        /// Altera dados na base de dados
        /// </summary>
        /// <param name="animalModel"></param>
        public void Editar(AnimalModel animalModel)
        {
            tb_animal animalE = new tb_animal();

            Atribuir(animalModel, animalE);
            unitOfWork.RepositorioAnimal.Editar(animalE);
            unitOfWork.Commit(shared);
        }
コード例 #23
0
 public HttpResponseMessage Add(AnimalModel model)
 {
     if (!ModelState.IsValid)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
     return(Request.CreateResponse(HttpStatusCode.OK, model));
 }
コード例 #24
0
ファイル: MyZooController.cs プロジェクト: LeznerPublic/MyZoo
        public IEnumerable <AnimalModel> AddAnimal([FromBody] AnimalModel animal)
        {
            var newId = (allAnimals.Select(x => x.Id).Max()) + 1;

            animal.Id = newId;
            allAnimals.Add(animal);
            return(allAnimals);
        }
コード例 #25
0
        public AnimalModel Post([FromBody] NewAnimalModel value)
        {
            var result = new AnimalModel(value.Name);

            _animals.Add(result);

            return(result);
        }
コード例 #26
0
ファイル: SubjectController.cs プロジェクト: DavidBlaa/mct
        public ActionResult Details(long id, string type)
        {
            SubjectManager sm = new SubjectManager();

            Subject s = sm.Get(id);

            //load by loading the page and store it in a session!!!!

            switch (type)
            {
            case "Plant":
            {
                Plant plant = sm.GetAll <Plant>().Where(p => p.Id.Equals(id)).FirstOrDefault();

                PlantModel Model = PlantModel.Convert(plant);
                //load interactions
                Model.Interactions = SubjectModel.ConverInteractionModels(sm.GetAllDependingInteractions(plant, true).ToList());

                return(View("PlantDetails", Model));
            }

            case "Animal":
            {
                Animal animal = sm.GetAll <Animal>().Where(a => a.Id.Equals(id)).FirstOrDefault();

                AnimalModel Model = AnimalModel.Convert(animal);
                Model.Interactions = SubjectModel.ConverInteractionModels(sm.GetAllDependingInteractions(animal, true).ToList());

                return(View("AnimalDetails", Model));
            }

            case "Taxon":
            {
                Taxon     taxon = sm.GetAll <Taxon>().Where(a => a.Id.Equals(id)).FirstOrDefault();
                NodeModel Model = NodeModel.Convert(taxon);

                return(View("TaxonDetails", Model));
            }

            case "Effect":
            {
                Effect effect = sm.GetAll <Effect>().Where(e => e.Id.Equals(id)).FirstOrDefault();

                return(View("EffectDetails"));
            }

            case "Unknow":
            {
                SubjectModel Model = SubjectModel.Convert(s);

                return(View("SubjectDetails", Model));
            }

            default: { break; }
            }

            return(RedirectToAction("Search", "Search"));;
        }
コード例 #27
0
        /// <summary>
        /// Insere um novo na base de dados
        /// </summary>
        /// <param name="animalModel">Dados do modelo</param>
        /// <returns>Chave identificante na base</returns>
        public int Inserir(AnimalModel animalModel)
        {
            tb_animal animalE = new tb_animal();

            Atribuir(animalModel, animalE);
            unitOfWork.RepositorioAnimal.Inserir(animalE);
            unitOfWork.Commit(shared);
            return(animalE.IDAnimal);
        }
コード例 #28
0
ファイル: AnimalService.cs プロジェクト: evilsquirr3l/trpz
        private void UpdateEntities(AnimalModel animal, FoodModel food)
        {
            var animalEntity = _mapper.Map <Animal>(animal);
            var foodEntity   = _mapper.Map <Food>(food);

            _unit.FoodRepository.Update(foodEntity);
            _unit.AnimalRepository.Update(animalEntity);
            _unit.Save();
        }
コード例 #29
0
        internal static void SeedTestAnimal(this LivestockContext context, long id)
        {
            var animal = new AnimalModel
            {
                Id = id
            };

            context.Animals.Add(animal);
        }
コード例 #30
0
        public RelatedPeopleViewModel(int animalID)
        {
            Animal = new AnimalModel();
            Animal.GetAnimal(animalID);

            Vet      = new PersonInfo();
            Owner    = new PersonInfo();
            NewOwner = new PersonInfo();
        }