Example #1
0
        public CTI<bool> AddUser(Users user) {
            try {
                using (var db = new UserContext()) {
                    var existingMatch = db.UsersDS.FromSql("SELECT * FROM Users WHERE Active = 1").Any(c => c.EmailAddress == user.EmailAddress);

                    if (existingMatch) {
                        return new CTI<bool>(false);
                    }

                    db.UsersDS.Add(user);

                    var result = db.SaveChanges();

                    if (result == 0) {
                        throw new Exception("Could not create account");
                    }
                    
                    var playerCharacter = new PlayerCharacters();

                    playerCharacter.AssetID = 7;
                    playerCharacter.ClassTypeID = 1;
                    playerCharacter.Experience = 0;
                    playerCharacter.LevelNumber = 1;
                    playerCharacter.Name = "N3WB";
                    playerCharacter.UserID = user.ID;

                    db.PlayerCharactersDS.Add(playerCharacter);

                    result = db.SaveChanges();

                    return new CTI<bool>(result > 0);
                }
            } catch (Exception ex) {
                return new CTI<bool>(false, ex.ToString());
            }
        }
Example #2
0
 public CTI<bool> PUT(Users user) {
     return new UserManager().AddUser(user);
 }
Example #3
0
 public async Task<CTI<bool>> AddUser(Users user) { return await PUT<Users, CTI<bool>>(user); }