Esempio n. 1
0
 public PetEntity Update(PetEntity petUpdate)
 {
     _PActx.Attach(petUpdate).State = EntityState.Modified;
     _PActx.Entry(petUpdate).Reference(p => p.Owner).IsModified = true;
     _PActx.SaveChanges();
     return(petUpdate);
 }
Esempio n. 2
0
        public IEnumerable <PetEntity> GetPets()
        {
            List <PetEntity> pets = new List <PetEntity>();
            MySqlConnection  databaseConnection = new MySqlConnection(connectionString);
            MySqlCommand     commandDatabase    = new MySqlCommand(query, databaseConnection);

            commandDatabase.CommandTimeout = 60;
            databaseConnection.Open();
            MySqlDataReader _reader = commandDatabase.ExecuteReader();

            if (_reader.HasRows)
            {
                while (_reader.Read())
                {
                    PetEntity pet = new PetEntity();
                    pet.Id          = _reader.GetInt32(0);
                    pet.Name        = _reader.GetString(1);
                    pet.Sex         = _reader.GetChar(2);
                    pet.Description = _reader.GetString(3);
                    pets.Add(pet);
                }
                databaseConnection.Close();
            }
            return(pets);
        }
Esempio n. 3
0
        /// <summary>
        /// 公司详情
        /// </summary>
        /// <returns></returns>
        public ActionResult PetDetail(int?keyValue)
        {
            PetEntity entity = petBll.GetEntity(keyValue);

            ViewBag.model = entity;
            return(View());
        }
Esempio n. 4
0
        public PetEntity Create(PetEntity pet)
        {
            var pets = _PActx.pets.Add(pet).Entity;

            _PActx.SaveChanges();
            return(pets);
        }
        public FetchSpecs(SqLiteNHibernateFixture fixture) : base(fixture) {
            using (var tx = Session.BeginTransaction()) {
                var person = new PersonEntity();

                CarEntity car;
                car = new CarEntity{Owner = person};
                person.Cars.Add(car);
                car = new CarEntity{Owner = person};
                person.Cars.Add(car);

                PetEntity pet;
                pet = new PetEntity {Owner = person};
                person.Pets.Add(pet);
                pet = new PetEntity {Owner = person};
                person.Pets.Add(pet);

                var employer = new EmployerEntity();
                Session.Save(employer);

                employer.Employees.Add(person);
                person.Employer = employer;
             
                Session.Save(person);
                tx.Commit();
            }

            Session.Clear();
            SessionFactory.Statistics.Clear();
        }
Esempio n. 6
0
 private void DespawnCharacter()
 {
     if (_petEntiy)
     {
         Pool.Controller.PoolController.instance.Despawn(_petEntiy.name, _petEntiy);
     }
     _petEntiy = null;
 }
Esempio n. 7
0
        /// <inheritdoc />
        public Task <PetEntity> Update(PetEntity pet)
        {
            IsExists(pet.Name);

            _context.Update(pet);
            _context.Save();
            return(Task.FromResult(pet));
        }
Esempio n. 8
0
        public PetEntity Create(PetEntity pet)
        {
            pet.Id = FakeDB.PetId++;
            var pets = FakeDB.Pets.ToList();

            pets.Add(pet);
            FakeDB.Pets = pets;
            return(pet);
        }
Esempio n. 9
0
        public ActionResult <PetEntity> Put(int id, [FromBody] PetEntity pet)
        {
            if (id < 1 || id != pet.Id)
            {
                return(BadRequest("Parameter Id and pet Id must be the same"));
            }

            return(Ok(_PetService.UpdatePet(pet)));
        }
        public string CompleteCustomer_Married_Child_Pet_Correct(IWebDriver driver)
        {
            customerEntity = repository.GetCustomer("Married");
            partnerEntity  = repository.GetPartner("Correct");
            childrenEntity = repository.GetChildren("Correct");
            petEntity      = repository.GetPet("Correct");

            summary.AccessToStep1(driver);

            customer.IntroduceFirstName(driver, customerEntity.FirstName);
            customer.IntroduceLastName(driver, customerEntity.LastName);
            customer.IntroduceBirthday(driver, customerEntity.Day, customerEntity.Month, customerEntity.Year);
            customer.IntroduceMatitalStatus(driver, customerEntity.MaritalStatus);
            customer.IntroducePostCode(driver, customerEntity.PostCode);
            customer.IntroduceNumber(driver, customerEntity.Address1);
            customer.IntroduceStreet(driver, customerEntity.Address2);
            customer.IntroduceVillage(driver, customerEntity.Town);
            customer.IntroducePhone(driver, customerEntity.Telephone);
            customer.ClickOnNext(driver);

            partner.IntroduceFirstName(driver, partnerEntity.FirstName);
            partner.IntroduceLastName(driver, partnerEntity.LastName);
            partner.IntroduceBirthday(driver, partnerEntity.Day, partnerEntity.Month, partnerEntity.Year);
            partner.IntroducePostCode(driver, partnerEntity.PostCode);
            partner.IntroduceNumber(driver, partnerEntity.Address1);
            partner.IntroduceStreet(driver, partnerEntity.Address2);
            partner.IntroduceVillage(driver, partnerEntity.Town);
            partner.ClickOnNext(driver);

            childrenExisting.ClickOnYes(driver);


            children.AddChild(driver);
            children.IntroduceFirstName(driver, childrenEntity.FirstName);
            children.IntroduceLastName(driver, childrenEntity.LastName);
            children.IntroduceBirthday(driver, childrenEntity.Day, childrenEntity.Month, childrenEntity.Year);
            children.IntroduceRelationship(driver, childrenEntity.Relation);
            children.IntroducePostcode(driver, childrenEntity.PostCode);
            children.IntroduceNumber(driver, childrenEntity.Number);
            children.IntroduceStreet(driver, childrenEntity.Street);
            children.IntroduceTown(driver, childrenEntity.Town);
            children.IntroduceCity(driver, childrenEntity.City);

            children.ClickOnSaveChild(driver);

            children.ClickOnNext(driver);

            petsExisting.ClickOnYes(driver);

            pets.AddPet(driver);
            pets.IntroduceName(driver, petEntity.Name);
            pets.IntroduceType(driver, petEntity.Type);
            pets.ClickOnSavePet(driver);
            pets.ClickOnNext(driver);

            return(driver.Url);
        }
Esempio n. 11
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="pet"></param>
        /// <returns></returns>
        public Task <PetEntity> Replace(PetEntity pet)
        {
            IsExists(pet.Name);
            Delete(pet.Name);
            var newpet = Create(pet);

            _context.Save();
            return(Task.FromResult(newpet.Result));
        }
 public override void Compose(Yupi.Protocol.ISender session, PetEntity pet, int amount)
 {
     using (ServerMessage message = Pool.GetMessageBuffer(Id))
     {
         message.AppendInteger(pet.Info.Id);
         message.AppendInteger(pet.Id);
         message.AppendInteger(amount);
         session.Send(message);
     }
 }
Esempio n. 13
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(int?keyValue, PetEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 14
0
        /// <inheritdoc />
        public Task <PetEntity> Update(PetEntity pet)
        {
            if (IsExists(pet.Name).Result)
            {
                _context.Update(pet);
                _context.Save();
                return(Task.FromResult(pet));
            }

            throw new NotFoundException(pet.Name + " NotFound");
        }
Esempio n. 15
0
 // PUT: api/Pet/5
 public void Put([FromBody] PetEntity value)
 {
     try
     {
         new PetRepository().Atualizar(value);
     }
     catch (Exception ex)
     {
         throw TratarErro(ex);
     }
 }
Esempio n. 16
0
 // POST: api/Pet
 public int Post([FromBody] PetEntity value)
 {
     try
     {
         return(new PetRepository().Inserir(value));
     }
     catch (Exception ex)
     {
         throw TratarErro(ex);
     }
 }
Esempio n. 17
0
        /// <summary>
        /// </summary>
        /// <param name="pet"></param>
        /// <returns></returns>
        public Task <PetEntity> Create(PetEntity pet)
        {
            var newpet = new PetEntity {
                Id = pet.Id, Description = pet.Description, Name = pet.Name
            };

            _context.Insert(newpet);
            _context.Save();

            return(Task.FromResult(newpet));
        }
Esempio n. 18
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="pet"></param>
        /// <returns></returns>
        public Task <PetEntity> Replace(PetEntity pet)
        {
            if (IsExists(pet.Name).Result)
            {
                Delete(pet.Name);
                var newpet = Create(pet);
                _context.Save();
                return(Task.FromResult(newpet.Result));
            }

            throw new NotFoundException(pet.Name + " NotFound");
        }
Esempio n. 19
0
        public PetEntity CreatePet(PetEntity petEntity)
        {
            int             retorno            = 0;
            MySqlConnection databaseConnection = new MySqlConnection(connectionString);

            databaseConnection.Open();
            MySqlCommand commandDatabase = new MySqlCommand($"Insert into  pets(Name, Sex, Description) values( '{petEntity.Name}','{petEntity.Sex}', '{petEntity.Description}' )", databaseConnection);

            retorno = commandDatabase.ExecuteNonQuery();
            databaseConnection.Close();
            return(petEntity);
        }
Esempio n. 20
0
        public PetEntity CreatePet(PetEntity petEntity)
        {
            var pet = Mapper.Map <PetEntity, Pet>(petEntity);

            using (var scope = new TransactionScope())
            {
                _unitOfWork.PetRepository.Insert(pet);
                _unitOfWork.Save();
                scope.Complete();
                petEntity.id = pet.Id;
                return(petEntity);
            }
        }
Esempio n. 21
0
        private IEnumerator RefreshPlayerModelCoroutine()
        {
            DespawnCharacter();
            TransformUtil.ClearChildren(playerModelRoot, true);
            yield return(new WaitForSeconds(0.3f));

            //			PlayerEntity.CreatePlayerEntityAsUIElement(GameProxy.instance.PlayerInfo,playerModelRoot,true,true);
            PetData petData = PetData.GetPetDataByID(GameProxy.instance.PlayerInfo.playerData.pet_id);

            _petEntiy = PlayerEntity.CreatePetEntiy(petData.modelName);
            _petEntiy.transform.SetParent(playerModelRoot, false);
            _petEntiy.transform.localScale       = petData.scale;
            _petEntiy.transform.localEulerAngles = petData.homeRotation;
            TransformUtil.SwitchLayer(_petEntiy.transform, (int)LayerType.UI);
        }
Esempio n. 22
0
        /// <summary>
        /// </summary>
        /// <param name="pet"></param>
        /// <returns></returns>
        public Task <PetEntity> Create(PetEntity pet)
        {
            var newpet = new PetEntity {
                Id = pet.Id, Description = pet.Description, Name = pet.Name
            };

            if (IsExists(pet.Name).Result)
            {
                throw new DuplicateWaitObjectException(pet.Name);
            }
            _context.Insert(newpet);
            _context.Save();

            return(Task.FromResult(newpet));
        }
Esempio n. 23
0
        public ActionResult <PetEntity> Post([FromBody] PetEntity pet)
        {
            if (string.IsNullOrEmpty(pet.Name))
            {
                return(BadRequest("Name is Required for Creating Pets"));
            }
            if (pet.Price < 0)
            {
                return(BadRequest("Price is Required for Creating Pets"));
            }
            if (string.IsNullOrEmpty(pet.Color))
            {
                return(BadRequest("Color is Required for Creating Pets"));
            }

            return(_PetService.CreatePets(pet));
        }
Esempio n. 24
0
        //Ny pet
        public PetEntity NewPet(string name, string type, string color,
                                DateTime birthDate, DateTime soldDate,
                                string previousOwner, double price)
        {
            var petNew = new PetEntity()
            {
                Name          = name,
                Type          = type,
                Color         = color,
                Birthdate     = birthDate,
                Solddate      = soldDate,
                PreviousOwner = previousOwner,
                Price         = price
            };

            return(petNew);
        }
Esempio n. 25
0
        //Updaterer pet sidste step
        public PetEntity Update(PetEntity petUpdate)
        {
            var petFromDB = this.ReadById(petUpdate.Id);

            if (petFromDB != null)
            {
                petFromDB.Name          = petUpdate.Name;
                petFromDB.Type          = petUpdate.Type;
                petFromDB.Color         = petUpdate.Color;
                petFromDB.Birthdate     = petUpdate.Birthdate;
                petFromDB.Solddate      = petUpdate.Solddate;
                petFromDB.PreviousOwner = petUpdate.PreviousOwner;
                petFromDB.Price         = petUpdate.Price;

                return(petFromDB);
            }
            return(null);
        }
Esempio n. 26
0
            private static Pet CreatePet(PetEntity entity)
            {
                switch (entity.Type)
                {
                case PetType.Cat:
                    return(new Cat {
                        Name = entity.Name
                    });

                case PetType.Dog:
                    return(new Dog {
                        Name = entity.Name
                    });

                default:
                    throw new InvalidOperationException();
                }
            }
Esempio n. 27
0
        public override void Compose(Yupi.Protocol.ISender room, PetEntity pet)
        {
            using (ServerMessage message = Pool.GetMessageBuffer(Id))
            {
                throw new NotImplementedException();

                /*
                 * message.AppendInteger(pet.Id);
                 * message.AppendInteger(pet.Info.Id);
                 * message.AppendInteger(pet.Info.RaceId);
                 * message.AppendInteger(pet.Info.Race);
                 * message.AppendString(pet.Info.Color.ToLower());
                 * if (pet.Info.HaveSaddle)
                 * {
                 *  message.AppendInteger(2);
                 *  message.AppendInteger(3);
                 *  message.AppendInteger(4);
                 *  message.AppendInteger(9);
                 *  message.AppendInteger(0);
                 *  message.AppendInteger(3);
                 *  message.AppendInteger(pet.Info.Hair);
                 *  message.AppendInteger(pet.Info.HairDye);
                 *  message.AppendInteger(3);
                 *  message.AppendInteger(pet.Info.Hair);
                 *  message.AppendInteger(pet.Info.HairDye);
                 * }
                 * else
                 * {
                 *  message.AppendInteger(1);
                 *  message.AppendInteger(2);
                 *  message.AppendInteger(2);
                 *  message.AppendInteger(pet.Info.Hair);
                 *  message.AppendInteger(pet.Info.HairDye);
                 *  message.AppendInteger(3);
                 *  message.AppendInteger(pet.Info.Hair);
                 *  message.AppendInteger(pet.Info.HairDye);
                 * }
                 * message.AppendBool(pet.Info.HaveSaddle);
                 *
                 * //message.AppendBool(pet.RidingHorse);
                 * room.Send(message);*/
            }
        }
Esempio n. 28
0
        public PetEntity UpdatePet(PetEntity petEntity)
        {
            int retorno = 0;

            MySqlConnection databaseConnection = new MySqlConnection(connectionString);

            databaseConnection.Open();

            MySqlCommand comando = new MySqlCommand($"Update pets set Name = '{petEntity.Name}', Sex='{ petEntity.Sex }', Description = '{petEntity.Description}' where Id = { petEntity.Id }", databaseConnection);

            retorno = comando.ExecuteNonQuery();

            databaseConnection.Close();

            return(petEntity);

            /*
             * var petToUpdate = GetPet(petEntity.Id);
             * petToUpdate.Name = petEntity.Name ?? petToUpdate.Name;
             * petToUpdate.Sex = petEntity.Sex ?? petToUpdate.Sex;
             * petToUpdate.Description = petEntity.Description ?? petToUpdate.Description;
             * return petToUpdate;*/
        }
Esempio n. 29
0
        public void Inserir_ValidPet_DoesntThrowException()
        {
            var pet = new PetEntity()
            {
                Nome            = "Hulk",
                Peso            = 58.6M,
                Vacinado        = true,
                Vermifugado     = false,
                Castrado        = null,
                Descricao       = "Cachorro teste, pastor alemão",
                IdAnimal        = 1,
                IdRaca          = 9,
                IdSexo          = Utilities.Conversor.EnumParaInt(Sexos.Macho),
                IdIdade         = Utilities.Conversor.EnumParaInt(Idades.Jovem),
                IdPorte         = Utilities.Conversor.EnumParaInt(Portes.Grande),
                IdPelo          = Utilities.Conversor.EnumParaInt(Pelos.Medio),
                IdCorPrimaria   = 3,
                IdCorSecundaria = 9,
                IdLoginCadastro = 1
            };

            new PetRepository().Inserir(pet);
        }
Esempio n. 30
0
        private void Serialize(ServerMessage messageBuffer, PetEntity pet)
        {
            messageBuffer.AppendInteger(pet.Id);
            messageBuffer.AppendString(pet.Info.Name);
            messageBuffer.AppendString(pet.Info.Motto);

            /*
             * if (pet.Info.Type == "pet_monster")
             *  messageBuffer.AppendString (pet.Info.MoplaBreed.PlantData);
             * else if (pet.Info.HaveSaddle == Convert.ToBoolean (2))
             *  messageBuffer.AppendString (string.Concat (pet.Info.Look.ToLower (), " 3 4 10 0 2 ", pet.Info.PetHair, " ",
             *      pet.Info.HairDye, " 3 ", pet.Info.PetHair, " ", pet.Info.HairDye));
             * else if (pet.Info.HaveSaddle == Convert.ToBoolean (1))
             *  messageBuffer.AppendString (string.Concat (pet.Info.Look.ToLower (), " 3 2 ", pet.Info.PetHair, " ",
             *      pet.Info.HairDye, " 3 ", pet.Info.PetHair, " ", pet.Info.HairDye, " 4 9 0"));
             * else
             *  messageBuffer.AppendString (string.Concat (pet.Info.Look.ToLower (), " 2 2 ", pet.Info.PetHair, " ",
             *      pet.Info.HairDye, " 3 ", pet.Info.PetHair, " ", pet.Info.HairDye));
             *
             * messageBuffer.AppendInteger (pet.Id);
             * messageBuffer.AppendInteger (pet.Position.X);
             * messageBuffer.AppendInteger (pet.Position.Y);
             * messageBuffer.AppendString (pet.Position.Z.ToString (CultureInfo.InvariantCulture));
             * messageBuffer.AppendInteger (0);
             * messageBuffer.AppendInteger (pet.Type);
             * messageBuffer.AppendInteger (pet.Info.RaceId);
             * messageBuffer.AppendInteger (pet.Info.Owner.Id);
             * messageBuffer.AppendString (pet.Info.Owner.Name);
             * messageBuffer.AppendInteger (pet.Info.Type == "pet_monster" ? 0 : 1);
             * messageBuffer.AppendBool (pet.Info.HaveSaddle);
             * messageBuffer.AppendBool (pet.RidingHorse);
             * messageBuffer.AppendInteger (0);
             * messageBuffer.AppendInteger (pet.Info.Type == "pet_monster" ? 1 : 0);
             * messageBuffer.AppendString (pet.Info.Type == "pet_monster" ? pet.Info.MoplaBreed.GrowStatus : "");
             */
            throw new NotImplementedException();
        }