Exemplo n.º 1
0
 public static bool ToShellEffectDTO(ShellEffect input, ShellEffectDTO output)
 {
     if (input == null)
     {
         return(false);
     }
     output.Effect            = input.Effect;
     output.EffectLevel       = input.EffectLevel;
     output.EquipmentSerialId = input.EquipmentSerialId;
     output.ShellEffectId     = input.ShellEffectId;
     output.Value             = input.Value;
     return(true);
 }
Exemplo n.º 2
0
        private static ShellEffectDTO Insert(ShellEffectDTO shelleffect, OpenNosContext context)
        {
            ShellEffect entity = new ShellEffect();

            Mapper.Mappers.ShellEffectMapper.ToShellEffect(shelleffect, entity);
            context.ShellEffect.Add(entity);
            context.SaveChanges();
            if (Mapper.Mappers.ShellEffectMapper.ToShellEffectDTO(entity, shelleffect))
            {
                return(shelleffect);
            }

            return(null);
        }
Exemplo n.º 3
0
 public IEnumerable <ShellEffectDTO> LoadByEquipmentSerialId(Guid id)
 {
     using (OpenNosContext context = DataAccessHelper.CreateContext())
     {
         List <ShellEffectDTO> result = new List <ShellEffectDTO>();
         foreach (ShellEffect entity in context.ShellEffect.AsNoTracking().Where(c => c.EquipmentSerialId == id))
         {
             ShellEffectDTO dto = new ShellEffectDTO();
             Mapper.Mappers.ShellEffectMapper.ToShellEffectDTO(entity, dto);
             result.Add(dto);
         }
         return(result);
     }
 }
Exemplo n.º 4
0
        private static ShellEffectDTO Update(ShellEffect entity, ShellEffectDTO shelleffect, OpenNosContext context)
        {
            if (entity != null)
            {
                Mapper.Mappers.ShellEffectMapper.ToShellEffect(shelleffect, entity);
                context.SaveChanges();
            }

            if (Mapper.Mappers.ShellEffectMapper.ToShellEffectDTO(entity, shelleffect))
            {
                return(shelleffect);
            }

            return(null);
        }
Exemplo n.º 5
0
        public ShellEffectDTO InsertOrUpdate(ShellEffectDTO shelleffect)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    long        shelleffectId = shelleffect.ShellEffectId;
                    ShellEffect entity        = context.ShellEffect.FirstOrDefault(c => c.ShellEffectId.Equals(shelleffectId));

                    if (entity == null)
                    {
                        return(Insert(shelleffect, context));
                    }
                    return(Update(entity, shelleffect, context));
                }
            }
            catch (Exception e)
            {
                Logger.Error(string.Format(Language.Instance.GetMessageFromKey("INSERT_ERROR"), shelleffect, e.Message), e);
                return(shelleffect);
            }
        }