partial void DeleteCharacter(Character instance);
 partial void InsertCharacter(Character instance);
 partial void UpdateCharacter(Character instance);
示例#4
0
        /// <summary>
        /// Creates a character in the DB.
        /// </summary>
        /// <param name="SimCharacter">The character to create.</param>
        public static CharacterCreationStatus CreateCharacter(Sim SimCharacter)
        {
            using (TSODataContext Context = new TSODataContext(DBConnectionManager.DBConnection))
            {
                Character Charac = new Character();
                Charac.Name = SimCharacter.Name;
                Charac.Sex = SimCharacter.Sex;
                Charac.LastCached = SimCharacter.Timestamp;
                Charac.GUID = SimCharacter.GUID;

                if (NameExistsInDB(SimCharacter.Name))
                    return CharacterCreationStatus.NameAlreadyExisted;

                if (SimCharacter.Account.NumCharacters == 3)
                    return CharacterCreationStatus.ExceededCharacterLimit;

                Context.Characters.InsertOnSubmit(Charac);
                Context.SubmitChanges();

                //Associate the character with the correct account.
                int CharID = GetCharacterID(Charac.Name);
                Account.CreateCharacter(SimCharacter.Account.AccountName, CharID);
            }

            return CharacterCreationStatus.Success;
        }