/// <summary>
 /// Saves the role.
 /// </summary>
 /// <param name="role">The role to save.</param>
 /// <returns>The saved role.</returns>
 protected abstract Role DoSaveRole(Role role);
        /// <summary>
        /// Saves the role.
        /// </summary>
        /// <param name="role">The role to save.</param>
        /// <returns>The saved role.</returns>
        protected override Role DoSaveRole(Role role)
        {
            MongoCollection<BsonDocument> collection = this.database.GetCollection(iApplyDb.Role._COLLECTION_NAME);
            BsonDocument newDocument = BsonConverter.ConvertToBsonViaJson(role);

            if (!role.IsNew)
            {
                BsonDocument existingDocument = collection.FindOneById(new BsonObjectId(new ObjectId(role.Id)));
                if (existingDocument != null && newDocument.EquivalentTo(existingDocument))
                {
                    return role;
                }

                collection.CopyDocumentToHistory(role.Id, iApplyDb.RoleHistory.ROLE_ID, string.Empty);
            }

            collection.Save(newDocument);
            return BsonConverter.ConvertToObjectViaJson<Role>(newDocument);
        }
 /// <summary>
 /// Saves the role.
 /// </summary>
 /// <param name="role">The role to save.</param>
 /// <returns>The saved role.</returns>
 public Role SaveRole(Role role)
 {
     return this.DoSaveRole(role);
 }