public static void UpdateUserSessionId(string userName, string sessionId) { using (var db = new BOTCContext()) { var user = db.User.Where(b => b.UserName == userName).FirstOrDefault(); user.SessionId = sessionId; db.SaveChanges(); } }
public static void DeleteItem(string itemId) { using (var db = new BOTCContext()) { var item = db.Item.Where(b => b.Id == int.Parse(itemId)).FirstOrDefault(); db.Remove(item); db.SaveChanges(); } }
//Items public static string CreateItem(Item item) { using (var db = new BOTCContext()) { db.Item.Add(item); db.SaveChanges(); } return(item.Name); }
public static void CreateUser(string userName, string password, string sessionId, string privileges) { using (var db = new BOTCContext()) { User user = new User() { UserName = userName, Password = password, SessionId = sessionId, Privileges = "" }; db.User.Add(user); db.SaveChanges(); } }
// //CreateClass saves new classes to db public static string CreateClass(string className, string totalHealth, string currentHealth, string strength, string dexterity) { using (var db = new BOTCContext()) { Classes newClass = new Classes() { Name = className, CurrentHealth = int.Parse(currentHealth), TotalHealth = int.Parse(totalHealth), Strength = int.Parse(strength), Dexterity = int.Parse(dexterity) }; db.Classes.Add(newClass); db.SaveChanges(); return(newClass.Id.ToString()); } }
// //CreateBandit saves new bandit to db public static string CreateBandit(string name, string sessionId, int classId) { using (var db = new BOTCContext()) { Classes banditClass = db.Classes.Where(c => c.Id == classId).FirstOrDefault(); User user = db.User.Where(u => u.SessionId == sessionId).FirstOrDefault(); Bandit bandit = new Bandit() { Name = name, CurrentHealth = 100, User = user, Class = banditClass }; db.Bandit.Add(bandit); db.SaveChanges(); return(bandit.Id.ToString()); } }
public static string CreateWeapon(Item item, Weapon weapon) { using (var db = new BOTCContext()) { db.Weapon.Add(weapon); db.SaveChanges(); } using (var db = new BOTCContext()) { item.Type_Id = weapon.Id; db.Item.Add(item); db.SaveChanges(); } return(item.Id.ToString()); }