コード例 #1
0
        public ActionResult AddAnimal(AnimalViewModel model)
        {
            if (ModelState.IsValid)
            {
                string[] arr = model.CareworkerName.Split(' ');

                if ((_context.Workers.ToList().Find(x => x.Name == arr[0]) != null) /*&& (_context.Workers.ToList().Find(x => x.Name == arr[0]) != null)*/ && (_context.Zoos.ToList().Find(x => x.Name == model.HomeZooName) != null))
                {
                    _context.Animals.Add(new Animal
                    {
                        Name        = model.Name,
                        Description = model.Description,
                        Cost        = model.Cost,
                        CareWorker  = _context.Workers.ToList().Find(x => x.Name == model.CareworkerName),
                        HomeZoo     = _context.Zoos.ToList().Find(x => x.Name == model.HomeZooName)
                    });
                    _context.SaveChanges();
                }
                else
                {
                    return(RedirectToAction("ErrorState", new { message = "Such worker or zoo doesn't exist!" }));
                }
            }

            return(RedirectToAction("ViewAllAnimals"));
        }
コード例 #2
0
        public IActionResult Update(int id, [FromBody] AnimalViewModel animal)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Animal _animalDb = _animalRepository.GetSingle(id);

            if (_animalDb == null)
            {
                return(NotFound());
            }
            else
            {
                _animalDb.Name        = animal.Name;
                _animalDb.DateOfBirth = animal.DateOfBirth;
                _animalDb.Breed       = animal.Breed;
                _animalDb.Description = animal.Description;
                _animalDb.Sex         = (AnimalSexEnum)Enum.Parse(typeof(AnimalSexEnum), animal.Sex);
                _animalDb.Size        = (AnimalSizeEnum)Enum.Parse(typeof(AnimalSizeEnum), animal.Size);
                _animalDb.Species     = (AnimalSpeciesEnum)Enum.Parse(typeof(AnimalSpeciesEnum), animal.Species);
                _animalDb.Avatar      = animal.Avatar;
            }

            _animalRepository.Commit();

            animal = Mapper.Map <Animal, AnimalViewModel>(_animalDb);

            return(new OkObjectResult(new { idAnimal = id }));
        }
コード例 #3
0
 public override void DestroySelf(AnimalViewModel viewModel)
 {
     base.DestroySelf (viewModel);
     InGameRoot.RemoveAnimal.OnNext (new RemoveAnimalCommand (){
         Argument = new AnimalProp(viewModel)
     });
 }
        private void FormVideoAnalyzerSelecionaAnimal_Load(object sender, EventArgs e)
        {
            _idCaixa          = Guid.Empty;
            _idTipoAnimal     = Guid.Empty;
            _idGrupo          = Guid.Empty;
            AnimalSelecionado = null;

            var grupos      = _gruproAppService.GetAll().Where(_ => _.StatusGrupo && _.IdUsuario == Guid.Parse(Settings.Default.Logado)).OrderBy(_ => _.IdGrupo).ToList();
            var tipoAnimais = _tipoAnimalAppService.GetAll().Where(_ => _.StatusTipoAnimal && _.IdUsuario == Guid.Parse(Settings.Default.Logado)).OrderBy(_ => _.IdTipoAnimal).ToList();
            var caixas      = _caixaAppService.GetAll().Where(_ => _.StatusCaixa && _.IdUsuario == Guid.Parse(Settings.Default.Logado)).OrderBy(_ => _.IdCaixa).ToList();

            comboGrupo.DataSource    = grupos;
            comboGrupo.DisplayMember = "NomeGrupo";
            comboGrupo.ValueMember   = "IdGrupo";

            comboTipoAnimal.DataSource    = tipoAnimais;
            comboTipoAnimal.DisplayMember = "NomeTipoAnimal";
            comboTipoAnimal.ValueMember   = "IdTipoAnimal";

            comboCaixa.DataSource    = caixas;
            comboCaixa.DisplayMember = "NomeCaixa";
            comboCaixa.ValueMember   = "IdCaixa";

            AnimalSelecionado = null;

            MontaComboAnimal();
            LimpaCampos();
        }
コード例 #5
0
        public UnauthAnimals(AnimalViewModel model)
        {
            vm          = model;
            DataContext = vm;

            InitializeComponent();
        }
コード例 #6
0
        public ActionResult Create(AnimalViewModel viewModel)
        {
            Animal Animal = new Animal();

            Animal.Name                = viewModel.Name;
            Animal.Description         = viewModel.Description;
            Animal.CategoryID          = viewModel.CategoryID;
            Animal.AnimalImageMappings = new List <AnimalImageMapping>();
            //get a list of selected images without any blanks
            string[] AnimalImages = viewModel.AnimalImages.Where(pi => !string.IsNullOrEmpty(pi)).ToArray();
            for (int i = 0; i < AnimalImages.Length; i++)
            {
                Animal.AnimalImageMappings.Add(new AnimalImageMapping
                {
                    AnimalImage = db.AnimalImages.Find(int.Parse(AnimalImages[i])),
                    ImageNumber = i
                });
            }

            if (ModelState.IsValid)
            {
                db.Animals.Add(Animal);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            viewModel.CategoryList = new SelectList(db.Categories, "ID", "Name", Animal.CategoryID);
            viewModel.ImageLists   = new List <SelectList>();
            for (int i = 0; i < Constants.NumberOfAnimalImages; i++)
            {
                viewModel.ImageLists.Add(new SelectList(db.AnimalImages, "ID", "FileName", viewModel.AnimalImages[i]));
            }
            return(View(viewModel));
        }
コード例 #7
0
        // GET: Animals/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Animal Animal = db.Animals.Find(id);

            if (Animal == null)
            {
                return(HttpNotFound());
            }
            AnimalViewModel viewModel = new AnimalViewModel();

            viewModel.CategoryList = new SelectList(db.Categories, "ID", "Name", Animal.CategoryID);
            viewModel.ImageLists   = new List <SelectList>();

            foreach (var imageMapping in Animal.AnimalImageMappings.OrderBy(pim => pim.ImageNumber))
            {
                viewModel.ImageLists.Add(new SelectList(db.AnimalImages, "ID", "FileName", imageMapping.AnimalImageID));
            }

            for (int i = viewModel.ImageLists.Count; i < Constants.NumberOfAnimalImages; i++)
            {
                viewModel.ImageLists.Add(new SelectList(db.AnimalImages, "ID", "FileName"));
            }

            viewModel.ID          = Animal.ID;
            viewModel.Name        = Animal.Name;
            viewModel.Description = Animal.Description;

            return(View(viewModel));
        }
コード例 #8
0
        public ActionResult Create(AnimalViewModel animalViewModel)
        {
            try
            {
                DadosComboBox();

                if (animalViewModel.SexoId <= 0)
                {
                    ModelState.AddModelError("", "É necessário informar o sexo do animal!");
                }

                if (ModelState.IsValid)
                {
                    var item = Mapper.Map <AnimalViewModel, Animal>(animalViewModel);
                    _iAnimalAppService.Add(item);

                    return(RedirectToAction("Index"));
                }

                return(View(animalViewModel));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #9
0
        // GET: SimpleZoo
        public ActionResult Index(string color, string habitat)
        {
            var foundAnimals = new List <IAnimal>();

            if (color == null && habitat == null)
            {
                foundAnimals = GetAllAnimalsinZoo().ToList(); //show all for now
            }
            else if (color == null)
            {
                foundAnimals = GetAllAnimalsinZoo().Where(x => x.Habitat.ToLower() == habitat.ToLower()).ToList();
            }
            else
            {
                foundAnimals = GetAllAnimalsinZoo().Where(x => x.Color.ToLower() == color.ToLower() && x.Habitat.ToLower() == habitat.ToLower()).ToList();
            }


            if (foundAnimals == null)
            {
                return(HttpNotFound());
            }


            var viewModel = new AnimalViewModel();

            {
                viewModel.Animals = foundAnimals;
            };

            return(View(viewModel));
        }
コード例 #10
0
        public ActionResult Create([Bind(Include = "AnimalID,TamanhoAnimal,RacaAnimal,Nome,Idade,Situacao,Resenha,ByteFoto,Imagem")] AnimalViewModel animalVM)
        {
            ValidaImagemModel(animalVM.Imagem);
            Animal animal = new Animal();

            if (ModelState.IsValid)
            {
                if (animalVM.Imagem != null)
                {
                    using (var binaryReader = new System.IO.BinaryReader(animalVM.Imagem.InputStream))
                        animal.Foto = binaryReader.ReadBytes(animalVM.Imagem.ContentLength);
                }

                animal.AnimalID      = Guid.NewGuid();
                animal.Nome          = animalVM.Nome;
                animal.RacaAnimal    = animalVM.RacaAnimal;
                animal.Situacao      = animalVM.Situacao;
                animal.TamanhoAnimal = animalVM.TamanhoAnimal;
                animal.Resenha       = animalVM.Resenha;
                animal.Idade         = animalVM.Idade;

                if (animal.Situacao == Enums.Situacao.DonoProprio)
                {
                    animal.UsuarioID = new Guid(Session["UsuarioID"].ToString());
                }

                _sisAdotContext.Animals.Add(animal);
                _sisAdotContext.SaveChanges();

                AddNotificacaoSucesso("Registro criado");
                return(RedirectToAction("Index"));
            }

            return(View(animal));
        }
コード例 #11
0
        public async Task <IActionResult> Edit(int id)
        {
            var userId = await _identityService.GetUserIdByNameAsync(User.Identity.Name);

            var animalCommand = new GetAnimalQuery
            {
                Id          = id,
                UserId      = userId,
                AnotherUser = false
            };

            var model = await _mediator.Send(animalCommand);

            if (model == null)
            {
                return(RedirectToAction("Index", "Profile"));
            }

            var animalViewModel = new AnimalViewModel
            {
                Id       = model.Id,
                UserId   = model.UserId,
                Nickname = model.Nickname,
                Passport = model.Passport,
                Kind     = model.Kind,
                Breed    = model.Breed,
                Features = model.Features,
                IsPublic = model.IsPublic
            };

            return(View(animalViewModel));
        }
コード例 #12
0
 public AnimalPage(INavigation navigation, int id)
 {
     InitializeComponent();
     _navigation      = navigation;
     _animalViewModel = new AnimalViewModel(this.Navigation, id);
     BindingContext   = _animalViewModel;
 }
コード例 #13
0
        // GET: Animal/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Animal animal = _sisAdotContext.Animals.Find(id);

            if (animal == null)
            {
                return(HttpNotFound());
            }
            AnimalViewModel animalViewModel = new AnimalViewModel()
            {
                AnimalID      = animal.AnimalID,
                Nome          = animal.Nome,
                RacaAnimal    = animal.RacaAnimal,
                Situacao      = animal.Situacao,
                TamanhoAnimal = animal.TamanhoAnimal,
                Resenha       = animal.Resenha,
                Idade         = animal.Idade,
                ByteFoto      = animal.Foto,
                UsuarioID     = animal.UsuarioID
            };

            return(View(animalViewModel));
        }
コード例 #14
0
        public async Task <IActionResult> Animal(string id)
        {
            try
            {
                var username = User.Identity.Name;
                var animal   = await _animalRepository.GetAnimal(username, id);

                var animalModel = new AnimalViewModel
                {
                    Id          = animal.Id,
                    Tag         = animal.Tag,
                    Status      = animal.Status == 1 ? true : false,
                    DateCreated = animal.DateCreated,
                    Picture     = animal.Picture
                };

                return(Ok(new AnimalRequestModel {
                    Status = "success", Message = "animals records successfully retrieved", Animal = animalModel
                }));
            }
            catch (Exception ex)
            {
                var response = new ErrorModel
                {
                    Status  = "error",
                    Message = $"{ex.Message}",
                };
                return(BadRequest(response));
            }
        }
コード例 #15
0
        public async Task <ActionResult> SavePet(Animal animal)
        {
            if (ModelState.IsValid)
            {
                if (animal.Id.Equals(null))
                {
                    await _animalRepository.Insert(animal);
                }
                else
                {
                    await _animalRepository.Update(animal);
                }

                await _animalRepository.SaveChangesAsync();

                return(RedirectToAction("Details", "Bites", new { biteId = animal.BiteId, Message = Constant.ManageMessageId.SavePetVictimDataSuccess }));
            }

            var PetFormViewModel = new AnimalViewModel
            {
                Animal    = animal,
                Breeds    = _breedRepository.All(),
                Specieses = _speciesRepository.All(),
                Employees = _employeeRepository.All(),
                Vets      = _vetRepository.All()
            };

            return(View("PetForm", PetFormViewModel));
        }
コード例 #16
0
 public ActionResult Details(int?id)
 { // A client can only see the details of its animals
     if (id != null)
     {
         using (IDal dal = new Dal())
         {
             Animal animal = dal.GetAnimalById((int)id);
             if (animal != null)
             {
                 AnimalViewModel vm = new AnimalViewModel(animal.IdAnimal);
                 if (HttpContext.User.IsInRole("Client"))
                 {
                     if (int.Parse(HttpContext.User.Identity.Name) == animal.IdUtilisateur)
                     {
                         return(View(vm));
                     }
                 }
                 if (HttpContext.User.IsInRole("Veterinary"))
                 {
                     return(View(vm));
                 }
                 return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
             }
             else
             {
                 return(HttpNotFound());
             }
         }
     }
     else
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
 }
コード例 #17
0
        public async Task <IActionResult> RemoveComment(int CommentId, [Bind("AnimalId")] AnimalComment animal)
        {
            AnimalComment commentary = (from c in _context.AnimalComment select c).Where(c => c.CommentId.Equals(CommentId)).First();

            _context.Remove(commentary);
            await _context.SaveChangesAsync();

            Animal fAnimal = await _context.Animals.FindAsync(animal.AnimalId);

            var rqf        = _httpContextAccessor.HttpContext.Features.Get <IRequestCultureFeature>();
            var culture    = rqf.RequestCulture.Culture;
            var breedsSet  = _context.AnimalBreeds;
            var speciesSet = _context.AnimalSpecies;

            var commentsSet = from c in _context.AnimalComment select c;

            commentsSet = commentsSet.Where(s => s.AnimalId.Equals(fAnimal.AnimalId));
            foreach (AnimalComment com in commentsSet)
            {
                var user = _context.Users.Where(u => u.Id.Equals(com.UserId)).First();
                com.SetEmail(user.Email);
                com.SetUserName(user.Name);
                com.SetUserImage(user.ImageURL);
            }

            var vs = new AnimalViewModel(fAnimal, culture, speciesSet, breedsSet, commentsSet);

            return(View("Details", vs));
        }
コード例 #18
0
        public async Task <IActionResult> Create(AnimalViewModel model)
        {
            if (ModelState.IsValid)
            {
                if ((this.User.Identity.Name != model.User.UserName) && !this.User.IsInRole("Admin"))
                {
                    return(NotFound());
                }

                var user = await _userHelper.GetUserByEmailAsync(model.User.UserName);

                if (user == null)
                {
                    return(NotFound());
                }

                var animal = _converterHelper.ToAnimal(model, true);

                animal.User = user;
                await _animalRepository.CreateAsync(animal);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
コード例 #19
0
        public async Task <IActionResult> AnimalInfo([FromForm] AnimalViewModel model)
        {
            string attachPath = string.Empty;

            if (model.formFile != null)
            {
                string fileName;
                string message = FileSave.SaveImage(out fileName, "Upload/Attachment/DocumentCategory", model.formFile);

                if (message == "success")
                {
                    attachPath = fileName;
                }
            }
            Animal animal = new Animal
            {
                Id           = (int)model.animalId,
                animalName   = model.animalName,
                animalNameBn = model.animalNameBn,
                imagePath    = attachPath
            };
            await lostAndFoundType.SaveAnimal(animal);

            return(RedirectToAction(nameof(AnimalInfo)));
        }
コード例 #20
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            var tipoAnimal = comboTipoAnimal.SelectedItem as TipoAnimalViewModel;
            var caixa      = comboCaixa.SelectedItem as CaixaViewModel;
            var grupo      = comboGrupo.SelectedItem as GrupoViewModel;

            var animal = new AnimalViewModel();

            animal.IdAnimal = Guid.NewGuid();
            if (caixa != null)
            {
                animal.IdCaixa = caixa.IdCaixa;
            }
            animal.Fezes = (double)numericQuantidadeDeFezes.Value;
            if (tipoAnimal != null)
            {
                animal.IdTipoAnimal = tipoAnimal.IdTipoAnimal;
            }

            animal.Peso         = txtPeso.Text ?? "0g";
            animal.Sexo         = comboSexo.SelectedItem.ToString();
            animal.StatusAnimal = comboStatus.RetornoComboBox("Habilitado");
            animal.IdUsuario    = Guid.Parse(Settings.Default.Logado);
            if (grupo != null)
            {
                animal.IdGrupo = grupo.IdGrupo;
            }
            animal.NomeAnimal = checkNomeAutomatico.Checked
                ? (caixa.NomeCaixa + grupo.NomeGrupo + animal.Sexo).Trim()
                : txtNomeAnimal.Text;
            animalAppService.Add(animal);
            LimpaComponentes();
            DesabilitaComponetes();
            AtualizaGrid();
        }
コード例 #21
0
        //
        // GET: /Randomization/Details/5

        public ActionResult Details(int animalid, int researchgroupid, int diseasemodelinductionid)
        {
            Animal animal = db.Animals.Find(animalid);

            if (animal == null)
            {
                return(HttpNotFound());
            }

            if (!_projectuservalidationservice.UserCanCreateAnimal(animal.Cohort.MultiPARTProjectMultiPARTProjectID))
            {
                ViewBag.ErrorMessage = "Access Denied. Please contact administrator for further assistance.";
                return(View("Error"));
            }

            AnimalViewModel animalVM = new AnimalViewModel
            {
                AnimalID                 = animal.AnimalID,
                AnimalLabel              = animal.AnimalLabel,
                CohortLabel              = animal.Cohort.CohortLabel,
                ProjectID                = animal.Cohort.MultiPARTProjectMultiPARTProjectID,
                ResearchgroupID          = researchgroupid,
                DiseasseModelInductionID = diseasemodelinductionid
            };

            ViewBag.projectid               = animalVM.ProjectID;
            ViewBag.researchgroupid         = researchgroupid;
            ViewBag.diseasemodelinductionid = diseasemodelinductionid;
            return(View(animalVM));
        }
コード例 #22
0
ファイル: AnimalView.xaml.cs プロジェクト: rn2629/Lab2_I-BDs
        public AnimalView()
        {
            InitializeComponent();

            //items = new List<Animal>();

            //Animal animal1 = new Animal();
            //animal1.Nom = "Tom";
            //animal1.Age = 79;
            //animal1.Type = "Chat";

            //Animal animal2 = new Animal();
            //animal2.Nom = "Nemo";
            //animal2.Age = 16;
            //animal2.Type = "Poisson";

            //Animal animal3 = new Animal();
            //animal3.Nom = "Zazou";
            //animal3.Age = 79;
            //animal3.Type = "Oiseau";

            //items.Add(animal1);
            //items.Add(animal2);
            //items.Add(animal3);
            //Animals.ItemsSource = items;


            DataContext = new AnimalViewModel();
        }
コード例 #23
0
 private bool Validate(AnimalViewModel model)
 {
     if (model.Name == "")
     {
         error = "El nombre es obligatorio";
     }
     return(true);
 }
コード例 #24
0
 public ActionResult Edit(AnimalViewModel animalViewModel)
 {
     if (ModelState.IsValid)
     {
         _animalAppService.Atualizar(animalViewModel);
         return(RedirectToAction("Index"));
     }
     return(View(animalViewModel));
 }
        public ActionResult EditAnimal(Guid?Id, AnimalViewModel model)
        {
            if (Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var animal = animalRP.FindGuid(Id);

            if (animal == null)
            {
                return(HttpNotFound());
            }

            if (model.Name != null)
            {
                animal.Name = model.Name;
            }
            if (model.Description != null)
            {
                animal.Description = model.Description;
            }
            if (model.MedicalHistory != null)
            {
                animal.MedicalHistory = model.MedicalHistory;
            }
            if (model.DietaryNeeds != null)
            {
                animal.DietaryNeeds = model.DietaryNeeds;
            }
            if (model.Behaviour != null)
            {
                animal.Behaviour = model.Behaviour;
            }
            if (model.BackgroundInfo != null)
            {
                animal.BackgroundInfo = model.BackgroundInfo;
            }
            if (model.HouseholdRequirements != null)
            {
                animal.HouseholdRequirements = model.HouseholdRequirements;
            }

            animal.Type   = model.Type;
            animal.Gender = model.Gender;
            animal.CompatibleWithChildren     = model.CompatibleWithChildren;
            animal.CompatibleWithOtherAnimals = model.CompatibleWithOtherAnimals;
            animal.Tag1 = model.Tag1;
            animal.Tag2 = model.Tag2;
            animal.Tag3 = model.Tag3;
            animal.Tag4 = model.Tag4;
            animal.Tag5 = model.Tag5;

            animalRP.Update(animal);

            return(View("AnimalDisplay", animal));
        }
コード例 #26
0
        public IActionResult Index(AnimalViewModel animalVM)
        {
            var pageNumber = (animalVM.Pnumber == 0) ? 1 : animalVM.Pnumber;
            var pageSize   = 10;
            var animals    = _AnimalRepository.GetAll().ToPagedList(pageNumber, pageSize);

            animalVM.Animals = animals;
            return(View(animalVM));
        }
コード例 #27
0
        public AnimalViewModel Atualizar(AnimalViewModel animalViewModel)
        {
            var animal = Mapper.Map <Animal>(animalViewModel);

            _animalService.Atualizar(animal);
            animal.Ativo = true;
            Commit();
            return(animalViewModel);
        }
コード例 #28
0
 public ActionResult Edit([Bind(Include = "Id,Nome,Raca,NomeDono")] AnimalViewModel animal)
 {
     if (ModelState.IsValid)
     {
         repository.Update(Mapper.Map <AnimalViewModel, Animal>(animal));
         RedirectToAction("Index");
     }
     return(View(animal));
 }
コード例 #29
0
 public ActionResult CadastrarAnimal(AnimalViewModel animalViewModel)
 {
     if (ModelState.IsValid)
     {
         repository.Insert(Mapper.Map <AnimalViewModel, Animal>(animalViewModel));
         return(RedirectToAction("Index"));
     }
     return(View(animalViewModel));
 }
コード例 #30
0
        public ActionResult Edit(AnimalViewModel viewModel)
        {
            var AnimalToUpdate = db.Animals.Include(p => p.AnimalImageMappings).Where(p => p.ID == viewModel.ID).Single();

            if (TryUpdateModel(AnimalToUpdate, "", new string[] { "Name", "Description", "Price", "CategoryID" }))
            {
                if (AnimalToUpdate.AnimalImageMappings == null)
                {
                    AnimalToUpdate.AnimalImageMappings = new List <AnimalImageMapping>();
                }
                //get a list of selected images without any blanks
                string[] AnimalImages = viewModel.AnimalImages.Where(pi => !string.IsNullOrEmpty(pi)).ToArray();
                for (int i = 0; i < AnimalImages.Length; i++)
                {
                    //get the image currently stored
                    var imageMappingToEdit = AnimalToUpdate.AnimalImageMappings.Where(pim => pim.ImageNumber == i).FirstOrDefault();
                    //find the new image
                    var image = db.AnimalImages.Find(int.Parse(AnimalImages[i]));
                    //if there is nothing stored then we need to add a new mapping
                    if (imageMappingToEdit == null)
                    {
                        //add image to the imagemappings
                        AnimalToUpdate.AnimalImageMappings.Add(new AnimalImageMapping
                        {
                            ImageNumber   = i,
                            AnimalImage   = image,
                            AnimalImageID = image.ID
                        });
                    }
                    //else it's not a new file so edit the current mapping
                    else
                    {
                        //if they are not the same
                        if (imageMappingToEdit.AnimalImageID != int.Parse(AnimalImages[i]))
                        {
                            //assign image property of the image mapping
                            imageMappingToEdit.AnimalImage = image;
                        }
                    }
                }
                //delete any other imagemappings that the user did not include in their selections for the Animal
                for (int i = AnimalImages.Length; i < Constants.NumberOfAnimalImages; i++)
                {
                    var imageMappingToEdit = AnimalToUpdate.AnimalImageMappings.Where(pim => pim.ImageNumber == i).FirstOrDefault();
                    //if there is something stored in the mapping
                    if (imageMappingToEdit != null)
                    {
                        //delete the record from the mapping table directly.
                        //just calling AnimalToUpdate.AnimalImageMappings.Remove(imageMappingToEdit) results in a FK error
                        db.AnimalImageMappings.Remove(imageMappingToEdit);
                    }
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(viewModel));
        }
コード例 #31
0
        public async Task <IActionResult> AnimalInfo()
        {
            AnimalViewModel model = new AnimalViewModel
            {
                animals = await lostAndFoundType.GetAnimals(),
                fLang   = _aLang.PerseLang("MasterData/AnimalEN.json", "MasterData/AnimalBN.json", Request.Cookies["lang"]),
            };

            return(View(model));
        }
コード例 #32
0
    public override void Tapped(AnimalViewModel viewModel)
    {
        base.Tapped (viewModel);

        Debug.Log ("tapped: " + viewModel.AnimalType);

        if (InGameRoot.CanTap) {
            InGameRoot.RefreshSameCount.OnNext (new RefreshSameCountCommand () {
                Argument = viewModel
            });
        } else {
            Debug.Log ("can not tap");
        }
    }
コード例 #33
0
 public virtual void RefreshSameCount(InGameRootViewModel viewModel, AnimalViewModel arg)
 {
 }
コード例 #34
0
 public virtual void Tapped(AnimalViewModel viewModel)
 {
 }
コード例 #35
0
 public virtual void StartDrop(AnimalViewModel viewModel)
 {
 }
コード例 #36
0
 public virtual void InitializeAnimal(AnimalViewModel viewModel)
 {
     // This is called when a AnimalViewModel is created
     viewModel.Tapped.Action = this.TappedHandler;
     viewModel.DestroySelf.Action = this.DestroySelfHandler;
     viewModel.StartDrop.Action = this.StartDropHandler;
     viewModel.GotDropTarget.Action = this.GotDropTargetHandler;
     viewModel.GotIdle.Action = this.GotIdleHandler;
     viewModel.DebugCommand.Action = this.DebugCommandHandler;
     AnimalViewModelManager.Add(viewModel);
 }
コード例 #37
0
 public virtual void GotIdle(AnimalViewModel viewModel)
 {
 }
コード例 #38
0
 public virtual void GotDropTarget(AnimalViewModel viewModel)
 {
 }
コード例 #39
0
 public override void GotIdle(AnimalViewModel viewModel)
 {
     base.GotIdle(viewModel);
     InGameRoot.CalcAnimalsCount.OnNext (new CalcAnimalsCountCommand ());
 }
コード例 #40
0
    public override void RefreshSameCount(InGameRootViewModel viewModel, AnimalViewModel arg)
    {
        base.RefreshSameCount (viewModel, arg);

        List <AnimalViewModel> list1 = new List<AnimalViewModel> ();
        List <AnimalViewModel> list2 = new List<AnimalViewModel> ();

        Loc loc0 = arg.Loc;
        AnimalType type0 = arg.AnimalType;
        Guid guid = Guid.NewGuid ();

        arg.guid = guid;
        list1.Add (arg);

        while (list1.Count > 0) {
            AnimalViewModel vm = list1 [0];
            list1.RemoveAt (0);
            list2.Add (vm);

            List<Loc> locList = Locator.AroundLoc (vm.Loc);
            foreach (Loc loc in locList) {
                AnimalViewModel _vm = this.GetAnimalAtLoc (viewModel, loc);
                if (_vm != null) {
                    if (_vm.guid != guid) {
                        if (_vm.AnimalType == type0) {
                            _vm.guid = guid;
                            list1.Add (_vm);
                        }
                    }
                }
            }
        }

        foreach (AnimalViewModel _vm in list2) {
            _vm.SameCount = list2.Count;

            if (_vm.SameCount >= viewModel.RuleInfo.DestroyLimitCount) {
                _vm.needDestroy = true;
            }
        }

        viewModel.CalcAnimalsCount.OnNext (new CalcAnimalsCountCommand ());
    }
コード例 #41
0
 public override void StartDrop(AnimalViewModel viewModel)
 {
     base.StartDrop(viewModel);
 }
コード例 #42
0
 public override void InitializeAnimal(AnimalViewModel viewModel)
 {
     base.InitializeAnimal (viewModel);
     // This is called when a CharacterViewModel is created
 }
コード例 #43
0
 public virtual void DebugCommand(AnimalViewModel viewModel)
 {
 }
コード例 #44
0
 public override void DebugCommand(AnimalViewModel viewModel)
 {
     base.DebugCommand(viewModel);
     Debug.Log (String.Format ("({0},{1})", viewModel.Loc.x, viewModel.Loc.y));
 }
コード例 #45
0
 public virtual void DestroySelf(AnimalViewModel viewModel)
 {
 }
コード例 #46
0
 public override void GotDropTarget(AnimalViewModel viewModel)
 {
     base.GotDropTarget(viewModel);
 }
コード例 #47
0
ファイル: AnimalProp.cs プロジェクト: wang-yichun/AnimalStory
 public AnimalProp(AnimalViewModel animal)
 {
     this.AnimalType = animal.AnimalType;
     this.Loc = animal.Loc;
 }
コード例 #48
0
 public virtual void ExecuteRefreshSameCount(AnimalViewModel arg)
 {
     InGameRoot.RefreshSameCount.OnNext(new RefreshSameCountCommand() { Sender = InGameRoot, Argument = arg });
 }