public static async Task <HeroEntity> GetHero(CloudTable table, string partitionKey, string rowKey)
        {
            try
            {
                TableOperation getOperation = TableOperation.Retrieve <HeroEntity>(partitionKey, rowKey);
                TableResult    result       = await table.ExecuteAsync(getOperation);

                HeroEntity heroEntity = result.Result as HeroEntity;

                if (heroEntity != null)
                {
                    Console.WriteLine("\t{0}\t{1}\t{2}\t{3}\t{4}\t{5}",
                                      heroEntity.PartitionKey,
                                      heroEntity.RowKey,
                                      heroEntity.ComicBookUniverse,
                                      heroEntity.YearFirstAppeared,
                                      heroEntity.Hometown,
                                      heroEntity.TeamAffiliation);
                }

                return(heroEntity);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Something went wrong. Exception thrown: {ex.Message}");
                Console.ReadLine();
                throw;
            }
        }
示例#2
0
        private void RegenerateInTeamHeroModels()
        {
            DespawnCharacter();
            for (int i = 0; i < 9; i++)
            {
                FormationPosition formationPosition = (FormationPosition)(i + 1);
                uint roleID = ManageHeroesProxy.instance.GetCharacterInstanceIDAt(formationPosition);
                //uint cachedRoleID = 0;
                //_cachedFormationDic.TryGetValue(formationPosition, out cachedRoleID);

                //if (roleID != cachedRoleID)
                //{
                TransformUtil.ClearChildren(roleModelRoots[i], true);
                if (!ManageHeroesProxy.instance.IsPositionEmpty(formationPosition))
                {
                    if (GameProxy.instance.IsPlayer(roleID))
                    {
                        PlayerInfo      playerInfo      = GameProxy.instance.PlayerInfo;
                        CharacterEntity characterEntity = CharacterEntity.CreatePlayerEntityAsUIElement(playerInfo, roleModelRoots[i], false, false);
                        _characters.Add(characterEntity);
                    }
                    else
                    {
                        HeroInfo   heroInfo   = HeroProxy.instance.GetHeroInfo(roleID);
                        HeroEntity heroEntity = CharacterEntity.CreateHeroEntityAsUIElement(heroInfo, roleModelRoots[i], false, false);
                        _characters.Add(heroEntity);
                    }
                }
                _cachedFormationDic.AddOrReplace(formationPosition, roleID);
                //}
                formationBaseImages[i].SetSprite(roleID > 0 || ManageHeroesProxy.instance.CurrentFormationTeamInfo.formationInfo.formationData.GetPosEnalbe(formationPosition) ? _formationOccupiedSprite : _formationNormalSprite);
                roleShadows[i].gameObject.SetActive(roleID > 0);
            }
        }
示例#3
0
    public override void OnExit()
    {
        base.OnExit();
        HeroEntity hero = action.entity;

        BattleManager.instance.RemoveEntity(action.entity.data.id);
    }
示例#4
0
    public override void Init(HeroEntity _entity, ComponentParam _param)
    {
        base.Init(_entity, _param);
        CannonComponentParam cannonParam = param as CannonComponentParam;

        mRotateSpeed = cannonParam.rotateSpeed;
    }
示例#5
0
        public async Task <IActionResult> Post([FromBody] NewHero newHero)
        {
            //TODO : Rev
            try
            {
                var heroEntity = new HeroEntity
                {
                    Id   = Guid.NewGuid(),
                    Name = newHero.Name
                };

                await _heroesRepository.CreateHero(heroEntity).ConfigureAwait(false);

                var hero = Mapper.Map <Hero>(heroEntity);

                return(Created(hero));
            }
            catch (Exception ex)
            {
                if (ex is ArgumentNullException)
                {
                    return(BadRequest());
                }

                _logger.LogError(ex, "Error creating hero.");
                return(StatusCode(500));
            }
        }
示例#6
0
        private List <HeroEntity> mockHeroes()
        {
            var hero1 = new HeroEntity()
            {
                Id   = 1,
                Name = "Schawrznagger"
            };
            var hero2 = new HeroEntity()
            {
                Id   = 2,
                Name = "Wonder Woman"
            };
            var hero3 = new HeroEntity()
            {
                Id   = 3,
                Name = "Jackie Chan"
            };
            var hero4 = new HeroEntity()
            {
                Id   = 4,
                Name = "Mike Tyson"
            };

            var heroesList = new List <HeroEntity>();

            heroesList.Add(hero1);
            heroesList.Add(hero2);
            heroesList.Add(hero3);
            heroesList.Add(hero4);

            return(heroesList);
        }
 private void RegenerateInTeamHeroModels()
 {
     DespawnCharacter();
     for (int i = 0; i < 9; i++)
     {
         TransformUtil.ClearChildren(roleModelRoots[i], true);
         FormationPosition formationPosition = (FormationPosition)(i + 1);
         if (!ExpeditionFormationProxy.instance.IsPositionEmpty(formationPosition))
         {
             uint roleID = ExpeditionFormationProxy.instance.GetCharacterInstanceIDAt(formationPosition);
             if (GameProxy.instance.IsPlayer(roleID))
             {
                 PlayerInfo   playerInfo   = GameProxy.instance.PlayerInfo;
                 PlayerEntity playerEntity = CharacterEntity.CreatePlayerEntityAsUIElement(playerInfo, roleModelRoots[i], false, false);
                 _characters.Add(playerEntity);
             }
             else
             {
                 HeroInfo   heroInfo   = HeroProxy.instance.GetHeroInfo(roleID);
                 HeroEntity heroEntity = CharacterEntity.CreateHeroEntityAsUIElement(heroInfo, roleModelRoots[i], false, false);
                 _characters.Add(heroEntity);
             }
             roleShadows[i].gameObject.SetActive(true);
             formationBaseButtons[i].GetComponent <Image>().SetSprite(_formationOccupiedSprite);
         }
         else
         {
             roleShadows[i].gameObject.SetActive(false);
             formationBaseButtons[i].GetComponent <Image>().SetSprite(ExpeditionFormationProxy.instance.FormationTeamInfo.formationInfo.formationData.GetPosEnalbe(formationPosition) ? _formationOccupiedSprite : _formationNormalSprite);
         }
     }
 }
示例#8
0
        public virtual void Move(GameTime gameTime, HeroEntity heroEntity)
        {
            Vector2 v;
            bool    flag;

            Move(Direction, gameTime, out v, out flag);
        }
示例#9
0
        private void UpdateLeadingHero()
        {
            _leadingEntity            = _heroInCaravans[0];
            _leadingEntity.EntityData = _heroInCaravans[0].EntityData;

            _leadingEntity.GetComponent <SpriteRenderer>().sprite = _heroInCaravans[0].EntityData.Sprite;
        }
示例#10
0
    public HeroEntity CreateHero(HeroData data, Transform parent = null)
    {
        if (GetEntity(data.id) != null)
        {
            Debug.LogError("重复ID");
            return(null);
        }

        HeroEntity entity = new HeroEntity();

        if (entity == null)
        {
            return(entity);
        }

        entity.Init(data);

        mEntityList.Add(entity);
        if (parent)
        {
            entity.gameObject.transform.SetParent(parent);
        }

        return(entity);
    }
        /// <summary>
        /// 创建角色
        /// </summary>
        /// <param name="heroId"></param>
        /// <param name="heroStar"></param>
        /// <returns></returns>
        public HeroInfo CreateHero(int heroId, int heroStar = 1)
        {
            PlayerInfo.SimpleHeroInfo heroInfo = new PlayerInfo.SimpleHeroInfo();
            heroInfo.RoleId    = DateTime.Now.Ticks;
            heroInfo.HeroId    = heroId;
            heroInfo.HeroLevel = PlayerInfo.Level;
            heroInfo.HeroStar  = heroStar;
            HeroEntity heroEntity = HeroDBModel.Instance.Get(heroId);

            heroInfo.SkillInfoList = new List <PlayerInfo.SimpleSkillInfo>();
            string[] skillArr = heroEntity.UesSkill.Split('|');
            for (int i = 0; i < skillArr.Length; i++)
            {
                PlayerInfo.SimpleSkillInfo skillInfo = new PlayerInfo.SimpleSkillInfo();
                skillInfo.SkillId    = skillArr[i].ToInt();
                skillInfo.SkillLevel = 1;
                heroInfo.SkillInfoList.Add(skillInfo);
            }
            HeroInfo info = PrepareHeroInfo(heroInfo);

            info.RoleId = heroInfo.RoleId;
            PlayerInfo.HeroList.Add(heroInfo);
            PlayerInfo.ToJson();
            return(info);
        }
        private HeroInfo PrepareHeroInfo(PlayerInfo.SimpleHeroInfo simpInfo)
        {
            HeroEntity      heroEntity      = HeroDBModel.Instance.Get(simpInfo.HeroId);
            HeroLevelEntity heroLevelEntity = HeroLevelDBModel.Instance.GetList().Find(x => x.Level == simpInfo.HeroLevel);
            JobEntity       jobEntity       = JobDBModel.Instance.Get(heroEntity.Job);
            HeroStarEntity  heroStarEntity  = HeroStarDBModel.Instance.GetList().Find(x => x.Star == simpInfo.HeroStar);

            if (heroLevelEntity != null || heroLevelEntity != null || jobEntity != null || heroStarEntity != null)
            {
                HeroInfo info = new HeroInfo();
                info.RoleId       = simpInfo.RoleId;
                info.RoleNickName = heroEntity.Name;
                info.Level        = heroLevelEntity.Level;
                info.MaxHP        = (int)(heroLevelEntity.Hp * heroEntity.Hp * jobEntity.Hp * heroStarEntity.Hp);
                info.CurrentHP    = info.MaxHP;
                info.PhyAtk       = (int)(heroLevelEntity.PhyAtk * heroEntity.PhyAtk * jobEntity.PhyAtk * heroStarEntity.PhyAtk);
                info.MgicAtk      = (int)(heroLevelEntity.MgicAtk * heroEntity.MgicAtk * jobEntity.MgicAtk * heroStarEntity.MgicAtk);
                info.Cri          = (int)(heroLevelEntity.Cri * heroEntity.Cri * jobEntity.Cri * heroStarEntity.Cri);
                info.CriValue     = (int)(heroLevelEntity.CriValue * heroEntity.CriValue * jobEntity.CriValue * heroStarEntity.CriValue);
                info.PhyDef       = (int)(heroLevelEntity.PhyDef * heroEntity.PhyDef * jobEntity.PhyDef * heroStarEntity.PhyDef);
                info.MgicDef      = (int)((heroLevelEntity.MgicDef * heroEntity.MgicDef * jobEntity.MgicDef * heroStarEntity.MgicDef));
                info.HeroID       = heroEntity.Id;
                info.JobID        = jobEntity.Id;
                info.HeroStar     = simpInfo.HeroStar;
                for (int j = 0; j < simpInfo.SkillInfoList.Count; j++)
                {
                    RoleInfoSkill skillInfo = new RoleInfoSkill();
                    skillInfo.SkillId    = simpInfo.SkillInfoList[j].SkillId;
                    skillInfo.SKillLevel = simpInfo.SkillInfoList[j].SkillLevel;
                    info.SkillList.Add(skillInfo);
                }
                return(info);
            }
            return(null);
        }
        //在平台上创建英雄
        public void CreateHero(long roleId, Vector2 screenPos)
        {
            HeroInfo info = Global.HeroInfoList.Find(x => x.RoleId == roleId);

            if (info != null)
            {
                HeroEntity heroEntity = HeroDBModel.Instance.Get(info.HeroID);
                GameObject go         = RoleMgr.Instance.LoadRole(RoleType.Hero, heroEntity.PrefabName);
                RoleCtrl   ctrl       = go.GetComponent <RoleCtrl>();
                ctrl.Init(RoleType.Hero, info, null);
                HeroPlatform platform = GetHeroPlatformByScreenPos(screenPos);
                platform.RefreshRoleId(ctrl.CurRoleInfo.RoleId);
                ctrl.RefreshPlatfrom(platform);
                ctrl.StandOnPlatfrom();
                go.transform.position = platform.transform.TransformPoint(platform.StandPos);
                bool inFoward = ForwardHeroPlatformList.Contains(platform);
                if (inFoward)
                {
                    AddHero(ctrl, true);
                }
                else
                {
                    AddHero(ctrl, false);
                }
                ctrl.OnRoleDestory += OnRoleDestoryCallBack;
                ctrl.OnRoleDie     += OnRoleDieCallBack;
                return;
            }
            Debug.Log("错误:在模拟服务器上找不到持有的英雄信息");
        }
示例#14
0
 /// <summary>
 /// 技能触发伤害
 /// </summary>
 public void OnTrigger(HeroEntity target)
 {
     if (target != null && target.IsDead() == false)
     {
         target.data.hp -= (entity.data.attack - target.data.defense);
     }
 }
示例#15
0
        public async Task CreateHero(HeroEntity heroEntity)
        {
            var heroDataModel = Mapper.Map <HeroDataModel>(heroEntity);

            await _context.Heroes.AddAsync(heroDataModel).ConfigureAwait(false);

            await _context.SaveChangesAsync().ConfigureAwait(false);
        }
 public void CreateHero(HeroEntity heroEntity)
 {
     if (heroEntity.Breed != null)
     {
         _dbContext.Entry(heroEntity.Breed).State = EntityState.Unchanged;
     }
     _dbContext.Heroes.Add(heroEntity);
 }
示例#17
0
    public override void Init(HeroEntity _entity, ComponentParam _param)
    {
        base.Init(_entity, _param);



        SetDestination(entity.position);
    }
示例#18
0
        private void RefreshHeroModels()
        {
            DespawnCharacter(true);
            int formationPositionCount = formationPositionList.Count;

            for (int formationPositionIndex = 0; formationPositionIndex < formationPositionCount; formationPositionIndex++)
            {
                roleTitleViewList[formationPositionIndex].gameObject.SetActive(false);
                formationPositionShadowList[formationPositionIndex].SetActive(false);
            }
            //Debugger.Log("RefreshHeroModels");
            List <uint> heroInstanceIDList = new List <uint>(ManageHeroesProxy.instance.CurrentFormationDictionary.Values);

            // 主角要一直站在中间
            heroInstanceIDList.Remove(GameProxy.instance.PlayerInfo.instanceID);
            heroInstanceIDList.Insert(0, GameProxy.instance.PlayerInfo.instanceID);
            int heroInstanceIDCount = heroInstanceIDList.Count;

            for (int i = 0; i < heroInstanceIDCount; i++)
            {
                if (GameProxy.instance.IsPlayer(heroInstanceIDList[i]))
                {
                    PlayerInfo playerInfo = GameProxy.instance.PlayerInfo;
                    //Debugger.Log("create role {0}", playerInfo.ModelName);
                    //PlayerEntity playerEntity = PlayerEntity.CreatePlayerEntityAsUIElement(playerInfo, formationPositionList[i].transform, true, false);
                    PlayerEntity.CreatePlayerEntityAsUIElement(playerInfo, formationPositionList[i].transform, true, false, (playerEntity) =>
                    {
                        _characters.Add(playerEntity);
                        Pool.Controller.PoolController.instance.SetPoolForever(playerInfo.playerData.model, true);
                    }, (petEntity) =>
                    {
                        if (petEntity)
                        {
                            Pool.Controller.PoolController.instance.SetPoolForever(petEntity.name, true);
                        }
                    });
                    formationPositionList[i].transform.localRotation = Quaternion.Euler(playerInfo.heroData.homeRotation);
                    roleTitleViewList[i].SetPlayerInfo(playerInfo);
                }
                else
                {
                    HeroInfo heroInfo = HeroProxy.instance.GetHeroInfo(heroInstanceIDList[i]);
                    //  Debugger.Log("create role {0}", heroInfo.ModelName);
                    //HeroEntity heroEntity = HeroEntity.CreateHeroEntityAsUIElement(heroInfo, formationPositionList[i].transform, true, false);
                    HeroEntity.CreateHeroEntityAsUIElement(heroInfo, formationPositionList[i].transform, true, false, (heroEntity) =>
                    {
                        _characters.Add(heroEntity);
                        Pool.Controller.PoolController.instance.SetPoolForever(heroInfo.ModelName, true);
                    });
                    formationPositionList[i].transform.localRotation = Quaternion.Euler(heroInfo.heroData.homeRotation);
                    roleTitleViewList[i].SetHeroInfo(heroInfo);
                }
                roleTitleViewList[i].gameObject.SetActive(true);
                formationPositionShadowList[i].SetActive(true);
            }
        }
示例#19
0
    public override void Init(HeroAction _skill, EffectParam _data, HeroEntity _parentTarget)
    {
        base.Init(_skill, _data, _parentTarget);
        FollowEffectParam move = param as FollowEffectParam;

        mSpeed = move.speed;

        mOffsetTo = move.offsetTo;
        OnBegin();
    }
        public bool DeleteHero(int heroId)
        {
            var heroToDelete = new HeroEntity()
            {
                Id = heroId
            };

            _dbContext.Entry(heroToDelete).State = EntityState.Deleted;
            return(true);
        }
示例#21
0
    public override void OnShow(params object[] paramsList)
    {
        HeroEntity entity = HeroManager.GetInstance().getHeroEntity(0);

        if (entity == null)
        {
            Debuger.LogError(" the hero entity is null");
        }
        labelLevel.text  = entity.Level.ToString();
        labelAttack.text = entity.GetAttributeValue(EBattleAttribute.ATTACK).ToString();
    }
示例#22
0
        private void InitSkill()
        {
            TransformUtil.ClearChildren(skillRootTran, true);
            _skillItemList.Clear();

            List <HeroEntity> heros = new List <HeroEntity>(PlayerController.instance.heros);

            if (heros.Count == 0)
            {
                return;
            }
            HeroEntity character = heros[0];

            _character = character;
            RoleInfo role = null;

            if (character is PlayerEntity)
            {
                role = PlayerController.instance.GetPlayerInfo();
            }
            else if (character is HeroEntity)
            {
                role = PlayerController.instance.GetHeroInfo(character.characterInfo.instanceID);
            }
            else
            {
                Debugger.LogError("these is not this type: " + character.GetType());
            }
            if (character.characterInfo.skillInfo1 != null)
            {
                IllustrationSkillItemButton btn = Instantiate <IllustrationSkillItemButton>(skillItemBtnPrefab);
                btn.transform.SetParent(skillRootTran, false);
                btn.gameObject.SetActive(true);
                btn.SetData((int)character.characterInfo.instanceID, character.characterInfo.skillInfo1);
                _skillItemList.Add(btn);
            }
            if (character.characterInfo.skillInfo2 != null)
            {
                IllustrationSkillItemButton btn = Instantiate <IllustrationSkillItemButton>(skillItemBtnPrefab);
                btn.transform.SetParent(skillRootTran, false);
                btn.gameObject.SetActive(true);
                btn.SetData((int)character.characterInfo.instanceID, character.characterInfo.skillInfo2);
                _skillItemList.Add(btn);
            }
//            if (character.characterInfo.aeonSkillInfo != null)
//            {
//                IllustrationSkillItemButton btn = Instantiate<IllustrationSkillItemButton>(skillItemBtnPrefab);
//                btn.transform.SetParent(skillRootTran, false);
//                btn.gameObject.SetActive(true);
//                btn.SetData((int)character.characterInfo.instanceID, character.characterInfo.aeonSkillInfo);
//                _skillItemList.Add(btn);
//            }
        }
示例#23
0
 public void Init(HeroEntity _entity)
 {
     entity = _entity;
     for (int i = 0; i < entity.param.actions.Count; ++i)
     {
         var        param  = entity.param.actions[i];
         HeroAction action = ObjectPool.GetInstance <HeroAction>();
         action.SetStateMachine(this);
         action.Init(_entity, param);
         mActions.Add(param.type, action);
     }
 }
示例#24
0
        public async Task <HeroEntity> UpdateHero(HeroEntity heroEntity)
        {
            var heroDataModel = await _context
                                .Heroes
                                .FirstOrDefaultAsync(hero => hero.Id == heroEntity.Id)
                                .ConfigureAwait(false);

            heroDataModel.Name = heroEntity.Name;

            await _context.SaveChangesAsync();

            return(Mapper.Map <HeroEntity>(heroDataModel));
        }
示例#25
0
        public Hero GenerateHero(HeroEntity heroEntity)
        {
            //TODO 生成一个英雄

            Hero hero = new Hero();

            //英雄ID
            hero.Id = heroEntity.UserID;
            //英雄名称
            hero.Name = heroEntity.Name;
            //英雄经验
            hero.Exp = heroEntity.TotalExp;

            CareerData careerData;

            StaticDataMgr.mInstance.mCareerDataMap.TryGetValue(heroEntity.CareerID, out careerData);
            RaceData raceData;

            StaticDataMgr.mInstance.mRaceDataMap.TryGetValue(heroEntity.RaceID, out raceData);
            if (careerData != null && raceData != null)
            {
                //职业数据
                hero.CareerData = careerData;
                //种族数据
                hero.RaceData = raceData;
                //职业技能
                for (int i = 0; i < careerData.AbilityList.Count; i++)
                {
                    CareerAbilityData careerAbilityData;
                    StaticDataMgr.mInstance.mCareerAbilityDataMap.TryGetValue(careerData.AbilityList[i], out careerAbilityData);
                    hero.CareerAbilities.Add(careerAbilityData);
                }
                //种族技能一
                RaceAbilityData raceAbilityData;
                StaticDataMgr.mInstance.mRaceAbilityDataMap.TryGetValue(raceData.AbilityOneID, out raceAbilityData);
                hero.RaceAbilitys.Add(raceAbilityData);
                StaticDataMgr.mInstance.mRaceAbilityDataMap.TryGetValue(raceData.AbilityTwoID, out raceAbilityData);
                hero.RaceAbilitys.Add(raceAbilityData);
                //血量
                hero.MaxHP = (int)(raceData.InitHP + GetGrowthValue(raceData.HPGrowth, hero.Level) + GetGrowthValue(careerData.HPGrowth, heroEntity.CareerLevel));
                //魔法
                hero.MaxMP = (int)(raceData.InitMP + GetGrowthValue(raceData.MPGrowth, hero.Level) + GetGrowthValue(careerData.MPGrowth, heroEntity.CareerLevel));
                //力量
                hero.Pow = raceData.InitPow + GetGrowthValue(raceData.PowGrowth, hero.Level) + GetGrowthValue(careerData.PowGrowth, heroEntity.CareerLevel);
                //体质
                hero.Con = raceData.InitCon + GetGrowthValue(raceData.ConGrowth, hero.Level) + GetGrowthValue(careerData.ConGrowth, heroEntity.CareerLevel);
                //敏捷
                hero.Dex = raceData.InitDex + GetGrowthValue(raceData.DexGrowth, hero.Level) + GetGrowthValue(careerData.DexGrowth, heroEntity.CareerLevel);
            }
            return(hero);
        }
示例#26
0
    public override void Init(HeroAction _skill, EffectParam _data, HeroEntity _parentTarget)
    {
        base.Init(_skill, _data, _parentTarget);

        if (parentTarget != null)
        {
            mRenderer = parentTarget.gameObject.GetComponentInChildren <MeshRenderer>();
            if (mRenderer != null)
            {
                mOldColor = mRenderer.material.color;
                mRenderer.material.color = (param as HitEffectParam).hitColor;
            }
        }
    }
        public async Task <bool> UpdateHeroAsync(HeroEntity heroEntity)
        {
            var heroToUpdate = await _dbContext.Heroes.FirstOrDefaultAsync(v => v.Id == heroEntity.Id);

            heroToUpdate.Name         = heroEntity.Name ?? heroToUpdate.Name;
            heroToUpdate.AttackType   = heroEntity.AttackType ?? heroToUpdate.AttackType;
            heroToUpdate.Difficulty   = heroEntity.Difficulty ?? heroToUpdate.Difficulty;
            heroToUpdate.HasStun      = heroEntity.HasStun ?? heroToUpdate.HasStun;
            heroToUpdate.Hp           = heroEntity.Hp ?? heroToUpdate.Hp;
            heroToUpdate.Level        = heroEntity.Level ?? heroToUpdate.Level;
            heroToUpdate.MainAtribute = heroEntity.MainAtribute ?? heroToUpdate.MainAtribute;
            heroToUpdate.Mana         = heroEntity.Mana ?? heroToUpdate.Mana;
            return(true);
        }
示例#28
0
        public void Setup(LevelGrid level, HeroSpawner heroSpawner, EnemySpawner enemySpawner)
        {
            _levelGrid    = level;
            _heroSpawner  = heroSpawner;
            _enemySpawner = enemySpawner;

            var defaultHero   = new GameObject("DefaultHero", typeof(SpriteRenderer));
            var currentEntity = defaultHero.AddComponent <HeroEntity>();

            currentEntity.Setup(heroSpawner.GetRandomHeroSprite());
            _heroInCaravans.Add(currentEntity);
            _leadingEntity            = currentEntity;
            _leadingEntity.EntityData = currentEntity.EntityData;
        }
示例#29
0
        public IActionResult Add(HeroEntity hero)
        {
            try
            {
                heroBusiness.Add(hero);
                return(Ok("Herói adicionado com sucesso!"));
            }
            catch (Exception e)
            {
                return(BadRequest("Não foi possível salvar o seu herói"));

                throw;
            }
        }
示例#30
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Welcome to the Heroes Table Storage sample!");

            Console.WriteLine("Let's connect to our table");

            string connectionString = AppSettings.LoadAppSettings().ConnectionString;

            CloudTableClient tableClient = TableHelpers.ConnectToClient(connectionString);

            CloudTable cloudTable = tableClient.GetTableReference("HeroesDB");

            List <HeroEntity> heroes = GenerateHeros();

            try
            {
                foreach (var hero in heroes)
                {
                    await OperationsHelper.InsertOrMergeHero(cloudTable, hero);
                }

                Console.WriteLine("Let's see if we can find Superman! Performing a read.");

                var superman = await OperationsHelper.GetHero(cloudTable, "Superman", "Clark Kent");

                Console.WriteLine("Wait, his hometown isn't right! Let's update it.");

                superman.Hometown = "Kryptonopolis";

                await OperationsHelper.InsertOrMergeHero(cloudTable, superman);

                Console.WriteLine("Let's 'snap' Tony Stark out of the Universe (too soon?).");

                HeroEntity tonyStark = await OperationsHelper.GetHero(cloudTable, "Iron Man", "Tony Stark");

                await OperationsHelper.DeleteHero(cloudTable, tonyStark);

                Console.WriteLine("Love you 3000");

                Console.WriteLine("Sample over. Press any key to exit....");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Something went wrong. Exception thrown: {ex.Message}");
                Console.ReadLine();
                throw;
            }
        }