public ScriptedInstance(ScriptedInstanceDTO input) { MapId = input.MapId; PositionX = input.PositionX; PositionY = input.PositionY; Script = input.Script; ScriptedInstanceId = input.ScriptedInstanceId; Type = input.Type; }
public IEnumerable <ScriptedInstanceDTO> LoadByMap(short mapId) { using (OpenNosContext context = DataAccessHelper.CreateContext()) { List <ScriptedInstanceDTO> result = new List <ScriptedInstanceDTO>(); foreach (ScriptedInstance timespaceObject in context.ScriptedInstance.AsNoTracking().Where(c => c.MapId.Equals(mapId))) { ScriptedInstanceDTO dto = new ScriptedInstanceDTO(); Mapper.Mappers.ScriptedInstanceMapper.ToScriptedInstanceDTO(timespaceObject, dto); result.Add(dto); } return(result); } }
public static bool ToScriptedInstanceDTO(ScriptedInstance input, ScriptedInstanceDTO output) { if (input == null) { return(false); } output.MapId = input.MapId; output.PositionX = input.PositionX; output.PositionY = input.PositionY; output.Script = input.Script; output.ScriptedInstanceId = input.ScriptedInstanceId; output.Type = input.Type; return(true); }
public static bool ToScriptedInstance(ScriptedInstanceDTO input, ScriptedInstance output) { if (input == null) { return(false); } output.MapId = input.MapId; output.PositionX = input.PositionX; output.PositionY = input.PositionY; output.Script = input.Script; output.ScriptedInstanceId = input.ScriptedInstanceId; output.Type = input.Type; output.QuestTimeSpaceId = input.QuestTimeSpaceId; output.IsSinglePortal = input.IsSinglePortal; return(true); }
public ScriptedInstanceDTO Insert(ScriptedInstanceDTO scriptedInstance) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { ScriptedInstance entity = new ScriptedInstance(); Mapper.Mappers.ScriptedInstanceMapper.ToScriptedInstance(scriptedInstance, entity); context.ScriptedInstance.Add(entity); context.SaveChanges(); if (Mapper.Mappers.ScriptedInstanceMapper.ToScriptedInstanceDTO(entity, scriptedInstance)) { return(scriptedInstance); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }