public DeleteResult Delete(long familylogId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { FamilyLog famlog = context.FamilyLog.FirstOrDefault(c => c.FamilyLogId.Equals(familylogId)); if (famlog != null) { context.FamilyLog.Remove(famlog); context.SaveChanges(); } return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Log.Error(string.Format(Language.Instance.GetMessageFromKey("DELETE_ERROR"), familylogId, e.Message), e); return(DeleteResult.Error); } }
public DeleteResult Delete(long id) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { CharacterRelation relation = context.CharacterRelation.SingleOrDefault(c => c.CharacterRelationId.Equals(id)); if (relation != null) { context.CharacterRelation.Remove(relation); context.SaveChanges(); } return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Log.Error(string.Format(Language.Instance.GetMessageFromKey("DELETE_CHARACTER_ERROR"), id, e.Message), e); return(DeleteResult.Error); } }
public DeleteResult Delete(int penaltylogid) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { PenaltyLog PenaltyLog = context.PenaltyLog.FirstOrDefault(c => c.PenaltyLogId.Equals(penaltylogid)); if (PenaltyLog != null) { context.PenaltyLog.Remove(PenaltyLog); context.SaveChanges(); } return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Log.Error(string.Format(Language.Instance.GetMessageFromKey("DELETE_PENALTYLOG_ERROR"), penaltylogid, e.Message), e); return(DeleteResult.Error); } }
public DeleteResult Delete(string characterName) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { Character character = context.Character.FirstOrDefault(c => c.Name.Equals(characterName) && c.State == (byte)CharacterState.Active); FamilyCharacter familyCharacter = context.FamilyCharacter.FirstOrDefault(c => c.CharacterId.Equals(character.CharacterId)); if (character != null && familyCharacter != null) { context.FamilyCharacter.Remove(familyCharacter); context.SaveChanges(); } return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Log.Error(string.Format(Language.Instance.GetMessageFromKey("DELETE_FAMILYCHARACTER_ERROR"), e.Message), e); return(DeleteResult.Error); } }
public DeleteResult Delete(long bazaarItemId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { BazaarItem BazaarItem = context.BazaarItem.FirstOrDefault(c => c.BazaarItemId.Equals(bazaarItemId)); if (BazaarItem != null) { context.BazaarItem.Remove(BazaarItem); context.SaveChanges(); } return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Log.Error(string.Format(Language.Instance.GetMessageFromKey("DELETE_ERROR"), bazaarItemId, e.Message), e); return(DeleteResult.Error); } }
public FamilyDTO LoadByCharacterId(long characterId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { FamilyCharacter familyCharacter = context.FamilyCharacter.FirstOrDefault(fc => fc.Character.CharacterId.Equals(characterId)); if (familyCharacter != null) { Family family = context.Family.FirstOrDefault(a => a.FamilyId.Equals(familyCharacter.FamilyId)); if (family != null) { return(_mapper.Map <FamilyDTO>(family)); } } } } catch (Exception e) { Logger.Error(e); } return(null); }
public DeleteResult DeleteById(long logId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { LogChat log = context.LogChat.First(i => i.LogId.Equals(logId)); if (log == null) { return(DeleteResult.Deleted); } context.LogChat.Remove(log); context.SaveChanges(); return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Error(e); return(DeleteResult.Error); } }
public SaveResult InsertOrUpdate(ref AccountDTO account) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { long accountId = account.AccountId; Account entity = context.Account.FirstOrDefault(c => c.AccountId.Equals(accountId)); if (entity == null) { account = Insert(account, context); return(SaveResult.Inserted); } account = Update(entity, account, context); return(SaveResult.Updated); } } catch (Exception e) { Logger.Log.Error(string.Format(Language.Instance.GetMessageFromKey("UPDATE_ACCOUNT_ERROR"), account.AccountId, e.Message), e); return(SaveResult.Error); } }
public DeleteResult DeleteById(long mailId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { Mail mail = context.Mail.First(i => i.MailId.Equals(mailId)); if (mail == null) { return(DeleteResult.Deleted); } context.Mail.Remove(mail); context.SaveChanges(); return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Error(e); return(DeleteResult.Error); } }
public SaveResult InsertOrUpdate(ref CharacterDTO character) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { long characterId = character.CharacterId; Character entity = context.Character.FirstOrDefault(c => c.CharacterId.Equals(characterId)); if (entity == null) { character = Insert(character, context); return(SaveResult.Inserted); } character = Update(entity, character, context); return(SaveResult.Updated); } } catch (Exception e) { Logger.Log.Error(string.Format(Language.Instance.GetMessageFromKey("INSERT_ERROR"), character, e.Message), e); return(SaveResult.Error); } }
public DeleteResult DeleteByPrimaryKey(long accountId, byte characterSlot) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { // actually a Character wont be deleted, it just will be disabled for future traces Character character = context.Character.SingleOrDefault(c => c.AccountId.Equals(accountId) && c.Slot.Equals(characterSlot) && c.State.Equals((byte)CharacterState.Active)); if (character != null) { character.State = (byte)CharacterState.Inactive; Update(character, _mapper.Map <CharacterDTO>(character), context); } return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Log.Error(string.Format(Language.Instance.GetMessageFromKey("DELETE_CHARACTER_ERROR"), characterSlot, e.Message), e); return(DeleteResult.Error); } }
private AccountDTO Update(Account entity, AccountDTO account, OpenNosContext context) { entity = _mapper.Map <Account>(account); context.SaveChanges(); return(_mapper.Map <AccountDTO>(entity)); }
private CharacterRelationDTO Update(CharacterRelation entity, CharacterRelationDTO relation, OpenNosContext context) { if (entity != null) { _mapper.Map(relation, entity); context.SaveChanges(); } return(_mapper.Map <CharacterRelationDTO>(entity)); }
private FamilyCharacterDTO Update(FamilyCharacter entity, FamilyCharacterDTO character, OpenNosContext context) { if (entity != null) { _mapper.Map(character, entity); context.SaveChanges(); } return(_mapper.Map <FamilyCharacterDTO>(entity)); }
private RespawnMapTypeDTO Update(RespawnMapType entity, RespawnMapTypeDTO respawnMapType, OpenNosContext context) { if (entity != null) { _mapper.Map(respawnMapType, entity); context.SaveChanges(); } return(_mapper.Map <RespawnMapTypeDTO>(entity)); }
private MinilandObjectDTO Update(MinilandObject entity, MinilandObjectDTO respawn, OpenNosContext context) { if (entity != null) { _mapper.Map(respawn, entity); context.SaveChanges(); } return(_mapper.Map <MinilandObjectDTO>(entity)); }