Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
 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();
     }
 }
Exemplo n.º 3
0
 //Items
 public static string CreateItem(Item item)
 {
     using (var db = new BOTCContext())
     {
         db.Item.Add(item);
         db.SaveChanges();
     }
     return(item.Name);
 }
Exemplo n.º 4
0
 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();
     }
 }
Exemplo n.º 5
0
 // //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());
     }
 }
Exemplo n.º 6
0
 // //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());
     }
 }
Exemplo n.º 7
0
        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());
        }