private readonly Ms2DbContext Context = new Ms2DbContext(); //Opens connection to database public void EquipItem(long characterId, long uid, string slot, bool isCosmetic = true) { Item item = Context.Items.FirstOrDefault(column => column.UniqueId == uid); // Query for item Item equippedItem; if (isCosmetic) // Handles cosmetic { equippedItem = Context.Items.Include(table => table.Inventory) .Where(column => column.Inventory.CharacterId == characterId) .FirstOrDefault(column => column.CosmeticSlot == slot.ToUpper()); if (equippedItem == null || equippedItem.CosmeticSlot == "") { UnequipItem(equippedItem.UniqueId, true); // Unequips item occupying slot } item.CosmeticSlot = slot.ToUpper(); // Sets the item slot location } else // Handles regular equipment { equippedItem = Context.Items.Include(table => table.Inventory) .Where(column => column.Inventory.CharacterId == characterId) .FirstOrDefault(column => column.EquipmentSlot == slot.ToUpper()); if (equippedItem != null) { UnequipItem(equippedItem.UniqueId, true); } item.EquipmentSlot = slot.ToUpper(); } Context.SaveChanges(); }
public static void CreateCharacter(long accountId, string characterName, int jobId) // Creates Character and Inventory { using (Ms2DbContext context = new Ms2DbContext()) { Character character = new Character() // Set default values here (Refer to character.cs for column names) { AccountId = accountId, Name = characterName, JobId = jobId, MapId = 2000062, CoordX = 2850, CoordY = 2550, CoordZ = 1800, Level = 70, PrestigeLvl = 100, Motto = "This works!", HomeName = "My Home Works!", InsigniaId = 29, TitleId = 10000292 }; context.Characters.Add(character); context.SaveChanges(); InventoryManager inventory = new InventoryManager(); character = context.Characters.First(column => column.Name.ToLower() == characterName.ToLower()); InventoryManager.CreateInventory(character.CharacterId); } }
public static void EditCharInfo(/*Character character*/) { using (Ms2DbContext context = new Ms2DbContext()) { context.SaveChanges(); } }
public static void EditItem(/*Item item*/) { using (Ms2DbContext context = new Ms2DbContext()) { context.SaveChanges(); } }
public static void EditSkill(/*SkillTree skill*/) { using (Ms2DbContext context = new Ms2DbContext()) { context.SaveChanges(); } }
public void EditCharInfo(Character character) { using (Ms2DbContext Context = new Ms2DbContext()) { Character Character = character; Context.SaveChanges(); } }
public void SetCharInfo(Character CharIn) { using (Ms2DbContext context = new Ms2DbContext()) { Character character = CharIn; context.SaveChanges(); } }
public void EditItem(Item item) { using (Ms2DbContext Context = new Ms2DbContext()) { Item Item = item; Context.SaveChanges(); } }
public static void UpdateItem(Item itemObject) { using (Ms2DbContext context = new Ms2DbContext()) { Item item = itemObject; context.SaveChanges(); } }
public void UpdateCharInfo(Character characterObject) { using (Ms2DbContext context = new Ms2DbContext()) { Character character = characterObject; context.SaveChanges(); } }
public void UpdateSkill(SkillTree skillObject) { using (Ms2DbContext context = new Ms2DbContext()) { SkillTree skill = skillObject; context.SaveChanges(); } }
public void EditSkill(SkillTree skill) { using (Ms2DbContext Context = new Ms2DbContext()) { SkillTree Skill = skill; Context.SaveChanges(); } }
public void DeleteAccount(long id) { using (Ms2DbContext Context = new Ms2DbContext()) { Account Account = Context.Accounts.Find(id); Context.Remove(Account); Context.SaveChanges(); } }
public static void DeleteCharacter(long characterId, string characterName = "") { using (Ms2DbContext context = new Ms2DbContext()) { Character character = context.Characters.FirstOrDefault(a => (a.CharacterId == characterId) || (a.Name.ToLower() == characterName.ToLower())); context.Remove(character); context.SaveChanges(); } }
public void DeleteCharacter(long characterId) { using (Ms2DbContext context = new Ms2DbContext()) { Character character = context.Characters.FirstOrDefault(column => column.CharacterId == characterId); context.Remove(character); context.SaveChanges(); } }
public static void DeleteAccount(long id) { using (Ms2DbContext context = new Ms2DbContext()) { Account account = context.Accounts.Find(id); context.Remove(account); context.SaveChanges(); } }
public static void DeleteSkill(long characterId, long skillId) { using (Ms2DbContext context = new Ms2DbContext()) { SkillTree skill = context.SkillTrees.Where(column => column.CharacterId == characterId) .FirstOrDefault(column => column.SkillId == skillId); context.Remove(skill); context.SaveChanges(); } }
public static void DeleteItem(long uid) { using (Ms2DbContext context = new Ms2DbContext()) { Item item = context.Items.Find(uid); context.Remove(item); context.SaveChanges(); } }
public void DeleteItem(long uid) { using (Ms2DbContext Context = new Ms2DbContext()) { Item Item = Context.Items.Find(uid); Context.Remove(Item); Context.SaveChanges(); } }
public void DeleteSkill(long characterId, long skillId) { using (Ms2DbContext Context = new Ms2DbContext()) { SkillTree Skill = Context.SkillTrees.Where(c => c.CharacterId == characterId) .FirstOrDefault(s => s.SkillId == skillId); Context.Remove(Skill); Context.SaveChanges(); } }
public static void CreateInventory(long characterId) { using (Ms2DbContext context = new Ms2DbContext()) { Inventory inventory = new Inventory() { CharacterId = characterId }; context.Add(inventory); context.SaveChanges(); } }
public IEnumerable <string> Get() { var obj = new ModelMS2(); obj.message2 = "MS2 Say Hello: " + DateTime.Now.ToString(); db.Entry(obj).State = EntityState.Added; db.SaveChanges(); _rabbitConnect.EsiPublish(obj.message2); return(new string[] { "MS2", obj.message2 }); }
public void CreateAccount(string username, string password) { using (Ms2DbContext Context = new Ms2DbContext()) { Account Account = new Account() { Username = username, Password = password }; Context.Accounts.Add(Account); Context.SaveChanges(); } }
public static void AddSkill(long characterId, long skillId, string skillName = "", int level = 0, bool learned = false) { using (Ms2DbContext context = new Ms2DbContext()) { SkillTree skill = new SkillTree() { CharacterId = characterId, SkillId = skillId, SkillName = skillName, Level = level, Learned = learned }; context.Add(skill); context.SaveChanges(); } }
public static void AddItem(long characterId, long itemId, long amount, int tab, int slot, int rarity) { using (Ms2DbContext context = new Ms2DbContext()) { Inventory inventory = context.Inventories.Find(characterId); Item item = new Item() { InventoryId = inventory.InventoryId, Id = itemId, Amount = amount, Tab = tab, Slot = slot, Rarity = rarity }; context.Add(item); context.SaveChanges(); } }
public void EditAccInfo(long id, string username = "", string password = "") // Allows account entry changes { using (Ms2DbContext Context = new Ms2DbContext()) { Account Account = Context.Accounts.FirstOrDefault(a => a.AccountId == id); // Retrieve entry by Id if (Account == null) // Checks to see if account Id exists { Debug.Assert(Account != null, "No entry starting with account ID: " + id); return; } if (!string.IsNullOrEmpty(username)) // Prevents empty entries { Account.Username = username; } if (!string.IsNullOrEmpty(password)) { Account.Password = password; } Context.SaveChanges(); // Updates database with changes. } }
public void CreateCharacter(long accId, string charName, int jobId) { using (Ms2DbContext context = new Ms2DbContext()) { Character character = new Character() // Set default values here (Refer to character.cs for column names) { AccountId = accId, Name = charName, JobId = jobId, MapId = 2000062, CoordX = 2850, CoordY = 2550, CoordZ = 1800, Level = 70, PrestigeLvl = 100, Motto = "This works!", HomeName = "My Home Works!", InsigniaId = 29, TitleId = 10000292 }; context.Characters.Add(character); context.SaveChanges(); } }