public RespawnDTO LoadById(long respawnId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { RespawnDTO dto = new RespawnDTO(); if (Mapper.Mapper.Instance.RespawnMapper.ToRespawnDTO(context.Respawn.FirstOrDefault(s => s.RespawnId.Equals(respawnId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public void Insert(List <ShopItemDTO> items) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { context.Configuration.AutoDetectChangesEnabled = false; foreach (ShopItemDTO Item in items) { ShopItem entity = _mapper.Map <ShopItem>(Item); context.ShopItem.Add(entity); } context.Configuration.AutoDetectChangesEnabled = true; context.SaveChanges(); } } catch (Exception e) { Logger.Error(e); } }
public void Insert(List <NpcMonsterDTO> npcs) { try { using (var context = DataAccessHelper.CreateContext()) { context.Configuration.AutoDetectChangesEnabled = false; foreach (NpcMonsterDTO Item in npcs) { NpcMonster entity = _mapper.Map <NpcMonster>(Item); context.NpcMonster.Add(entity); } context.Configuration.AutoDetectChangesEnabled = true; context.SaveChanges(); } } catch (Exception e) { Logger.Error(e); } }
public ShopDTO LoadByNpc(int mapNpcId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { ShopDTO dto = new ShopDTO(); if (Mapper.Mappers.ShopMapper.ToShopDTO(context.Shop.FirstOrDefault(s => s.MapNpcId.Equals(mapNpcId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public PenaltyLogDTO LoadById(int penaltyLogId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { PenaltyLogDTO dto = new PenaltyLogDTO(); if (Mapper.Mappers.PenaltyLogMapper.ToPenaltyLogDTO(context.PenaltyLog.AsNoTracking().FirstOrDefault(s => s.PenaltyLogId.Equals(penaltyLogId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public RecipeItemDTO LoadById(short recipeItemId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { RecipeItemDTO dto = new RecipeItemDTO(); if (Mapper.Mappers.RecipeItemMapper.ToRecipeItemDTO(context.RecipeItem.AsNoTracking().FirstOrDefault(s => s.RecipeItemId.Equals(recipeItemId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public QuestLogDTO LoadById(long id) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { QuestLogDTO dto = new QuestLogDTO(); if (Mapper.Mappers.QuestLogMapper.ToQuestLogDTO(context.QuestLog.FirstOrDefault(i => i.Id.Equals(id)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public void Insert(List <ItemCardDTO> itemCards) { try { using (var context = DataAccessHelper.CreateContext()) { context.Configuration.AutoDetectChangesEnabled = false; foreach (ItemCardDTO itemCard in itemCards) { ItemCard entity = _mapper.Map <ItemCard>(itemCard); context.ItemCard.Add(entity); } context.Configuration.AutoDetectChangesEnabled = true; context.SaveChanges(); } } catch (Exception e) { Logger.Error(e); } }
public MapTypeMapDTO LoadByMapAndMapType(short mapId, short maptypeId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { MapTypeMapDTO dto = new MapTypeMapDTO(); if (Mapper.Mappers.MapTypeMapMapper.ToMapTypeMapDTO(context.MapTypeMap.FirstOrDefault(i => i.MapId.Equals(mapId) && i.MapTypeId.Equals(maptypeId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public ComboDTO LoadById(short comboId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { ComboDTO dto = new ComboDTO(); if (Mapper.Mappers.ComboMapper.ToComboDTO(context.Combo.FirstOrDefault(s => s.SkillVNum.Equals(comboId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public void Insert(List <BCardDTO> cards) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { context.Configuration.AutoDetectChangesEnabled = false; foreach (BCardDTO card in cards) { BCard entity = _mapper.Map <BCard>(card); context.BCard.Add(entity); } context.Configuration.AutoDetectChangesEnabled = true; context.SaveChanges(); } } catch (Exception e) { Logger.Error(e); } }
public WarpPointDTO LoadById(short warppointID) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { WarpPointDTO dto = new WarpPointDTO(); if (Mapper.Mappers.WarpPointMapper.ToWarpPointDTO(context.WarpPoint.FirstOrDefault(i => i.WarpPointID.Equals(warppointID)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public void Insert(List <ActPartDTO> actParts) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { context.Configuration.AutoDetectChangesEnabled = false; foreach (ActPartDTO actPart in actParts) { ActPart entity = new ActPart(); context.ActPart.Add(entity); } context.Configuration.AutoDetectChangesEnabled = true; context.SaveChanges(); } } catch (Exception e) { Logger.Error(e); } }
public MaintenanceLogDTO LoadFirst() { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { MaintenanceLogDTO dto = new MaintenanceLogDTO(); if (Mapper.Mapper.Instance.MaintenanceLogMapper.ToMaintenanceLogDTO(context.MaintenanceLog.FirstOrDefault(m => m.DateEnd > DateTime.Now), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public void Insert(List <ShopSkillDTO> skills) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { context.Configuration.AutoDetectChangesEnabled = false; foreach (ShopSkillDTO Skill in skills) { ShopSkill entity = _mapper.Map <ShopSkill>(Skill); context.ShopSkill.Add(entity); } context.Configuration.AutoDetectChangesEnabled = true; context.SaveChanges(); } } catch (Exception e) { Logger.Error(e); } }
public void Insert(List <MapDTO> maps) { try { using (var context = DataAccessHelper.CreateContext()) { context.Configuration.AutoDetectChangesEnabled = false; foreach (MapDTO Item in maps) { Map entity = _mapper.Map <Map>(Item); context.Map.Add(entity); } context.Configuration.AutoDetectChangesEnabled = true; context.SaveChanges(); } } catch (Exception e) { Logger.Error(e); } }
public CardDTO LoadById(short cardId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { CardDTO dto = new CardDTO(); if (Mapper.Mapper.Instance.CardMapper.ToCardDTO(context.Card.FirstOrDefault(s => s.CardId.Equals(cardId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public MultiAccountExceptionDTO LoadByAccount(long accountId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { MultiAccountExceptionDTO dto = new MultiAccountExceptionDTO(); if (Mapper.Mappers.MultiAccountExceptionMapper.ToMultiAccountExceptionDTO(context.MultiAccountException.AsNoTracking().FirstOrDefault(s => s.AccountId.Equals(accountId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public MapMonsterDTO LoadById(int mapMonsterId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { MapMonsterDTO dto = new MapMonsterDTO(); if (Mapper.Mapper.Instance.MapMonsterMapper.ToMapMonsterDTO(context.MapMonster.FirstOrDefault(i => i.MapMonsterId == mapMonsterId), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public IEnumerable <TDTO> InsertOrUpdate(IEnumerable <TDTO> dtos) { try { IList <TDTO> results = new List <TDTO>(); using (var context = DataAccessHelper.CreateContext()) { foreach (TDTO dto in dtos) { results.Add(InsertOrUpdate(context, dto)); } } return(results); } catch (Exception e) { Logger.Log.Error(String.Format(Language.Instance.GetMessageFromKey("UPDATE_ERROR"), e.Message), e); return(Enumerable.Empty <TDTO>()); } }
public MapDTO LoadById(short mapId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { MapDTO dto = new MapDTO(); if (Mapper.Mapper.Instance.MapMapper.ToMapDTO(context.Map.FirstOrDefault(c => c.MapId.Equals(mapId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public QuestDTO InsertOrUpdate(QuestDTO quest) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { Quest entity = context.Quest.Find(quest.QuestId); if (entity == null) { return(insert(quest, context)); } return(update(entity, quest, context)); } } catch (Exception e) { Logger.Error(string.Format(Language.Instance.GetMessageFromKey("INSERT_ERROR"), quest, e.Message), e); return(quest); } }
public RecipeDTO LoadByItemVNum(short itemVNum) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { RecipeDTO dto = new RecipeDTO(); if (Mapper.Mappers.RecipeMapper.ToRecipeDTO(context.Recipe.SingleOrDefault(s => s.ItemVNum.Equals(itemVNum)), dto)) { return dto; } return null; } } catch (Exception e) { Logger.Error(e); return null; } }
public DeleteResult Delete(long characterId, long questId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { CharacterQuest charQuest = context.CharacterQuest.FirstOrDefault(i => i.CharacterId == characterId && i.QuestId == questId); if (charQuest != null) { context.CharacterQuest.Remove(charQuest); context.SaveChanges(); } return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Error(e); return(DeleteResult.Error); } }
public DeleteResult Delete(long characterId, short skillVNum) { try { using (var context = DataAccessHelper.CreateContext()) { CharacterSkill invItem = context.CharacterSkill.FirstOrDefault(i => i.CharacterId == characterId && i.SkillVNum == skillVNum); if (invItem != null) { context.CharacterSkill.Remove(invItem); context.SaveChanges(); } return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Error(e); return(DeleteResult.Error); } }
public NpcMonsterDTO LoadByVNum(short npcMonsterVNum) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { NpcMonsterDTO dto = new NpcMonsterDTO(); if (Mapper.Mappers.NpcMonsterMapper.ToNpcMonsterDTO(context.NpcMonster.FirstOrDefault(i => i.NpcMonsterVNum.Equals(npcMonsterVNum)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public MapNpcDTO LoadById(int mapNpcId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { MapNpcDTO dto = new MapNpcDTO(); if (Mapper.Mappers.MapNpcMapper.ToMapNpcDTO(context.MapNpc.FirstOrDefault(i => i.MapNpcId.Equals(mapNpcId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public TeleporterDTO LoadById(short teleporterId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { TeleporterDTO dto = new TeleporterDTO(); if (Mapper.Mappers.TeleporterMapper.ToTeleporterDTO(context.Teleporter.AsNoTracking().FirstOrDefault(i => i.TeleporterId.Equals(teleporterId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
public void Insert(List <ComboDTO> combos) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { context.Configuration.AutoDetectChangesEnabled = false; foreach (ComboDTO combo in combos) { Combo entity = _mapper.Map <Combo>(combo); context.Combo.Add(entity); } context.Configuration.AutoDetectChangesEnabled = true; context.SaveChanges(); } } catch (Exception e) { Logger.Error(e); } }
public ShopItemDTO LoadById(int itemId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { ShopItemDTO dto = new ShopItemDTO(); if (Mapper.Mappers.ShopItemMapper.ToShopItemDTO(context.ShopItem.FirstOrDefault(i => i.ShopItemId.Equals(itemId)), dto)) { return(dto); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }