Ejemplo n.º 1
0
        public AbilityVO FindOrCreate(AbilityVO item)
        {
            var ent = _converter.Parse(item);

            ent = _repository.FindOrCreate(ent);
            return(_converter.Parse(ent));
        }
Ejemplo n.º 2
0
        public AbilityVO Update(AbilityVO item)
        {
            var ent = _converter.Parse(item);

            ent = _repository.Update(ent);
            return(_converter.Parse(ent));
        }
Ejemplo n.º 3
0
        public IActionResult Post([FromBody] AbilityVO item)
        {
            if (item == null)
            {
                return(BadRequest());
            }
            var createdItem = _business.Create(item);

            if (createdItem == null)
            {
                return(BadRequest());
            }
            return(new OkObjectResult(createdItem));
        }
Ejemplo n.º 4
0
        public IActionResult Put([FromBody] AbilityVO item)
        {
            if (item == null)
            {
                return(BadRequest());
            }
            var updatedItem = _business.Update(item);

            if (updatedItem == null)
            {
                return(NoContent());
            }
            return(new OkObjectResult(updatedItem));
        }
Ejemplo n.º 5
0
        public AbilityVO Create(AbilityVO item)
        {
            var ent = _converter.Parse(item);

            try
            {
                ent = _repository.CreateAbility(ent);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(_converter.Parse(ent));
        }
Ejemplo n.º 6
0
        private void CreateHeroeAbilities(List <string> list, ref HeroeVO createdItem, int type)
        {
            HeroeAbility h = new HeroeAbility {
                idObjectA = createdItem.Id ?? default(long)
            };

            var errou = false;

            foreach (string s in list)
            {
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }

                AbilityVO vo = new AbilityVO {
                    Name = s.ToLower(), Type = type
                };
                try
                {
                    var ret = _ability.FindByExactName(vo.Name, (enAbility)vo.Type);

                    if (ret.Id == null)
                    {
                        ret = _ability.Create(vo);
                    }

                    h.idObjectB = ret.Id ?? default(long);
                    _heroeAbility.Create(h);
                }
                catch
                {
                    if (!errou)
                    {
                        _logger.Information("> " + createdItem.Name + " - Ability " + type.ToString());
                        errou = true;
                    }
                    _logger.Error(s);
                }
            }
        }