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); }
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); }
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); }
public void InsertOrUpdateFromList(List <ShellEffectDTO> shellEffects, Guid equipmentSerialId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { void Insert(ShellEffectDTO shelleffect) { ShellEffect entity = new ShellEffect(); Mapper.Mappers.ShellEffectMapper.ToShellEffect(shelleffect, entity); context.ShellEffect.Add(entity); context.SaveChanges(); shelleffect.ShellEffectId = entity.ShellEffectId; } void Update(ShellEffect entity, ShellEffectDTO shelleffect) { if (entity != null) { Mapper.Mappers.ShellEffectMapper.ToShellEffect(shelleffect, entity); } } foreach (ShellEffectDTO item in shellEffects) { item.EquipmentSerialId = equipmentSerialId; ShellEffect entity = context.ShellEffect.FirstOrDefault(c => c.ShellEffectId == item.ShellEffectId); if (entity == null) { Insert(item); } else { Update(entity, item); } } context.SaveChanges(); } } catch (Exception e) { Logger.Error(e); } }
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); } }
public ShellInfo(int damage, int velocity, ShellEffect effect = null) { Damage = damage; Velocity = velocity; }