protected void DeleteEntity(DSClient client, int userId, string token, ModelEntity entity)
 {
     if (entity is Application)
     {
         client.DeleteApplication(userId, token, (entity as Application).Id);
     }
     else if (entity is Role)
     {
         client.DeleteRole(userId, token, (entity as Role).Id);
     }
     else if (entity is Command)
     {
         client.DeleteCommand(userId, token, (entity as Command).Id);
     }
     else if (entity is RoleCommand)
     {
         client.DeleteRoleCommand(userId, token, (entity as RoleCommand).Id);
     }
     else if (entity is RoleCommandView)
     {
         client.DeleteRoleCommand(userId, token, (entity as RoleCommandView).Id);
     }
     else if (entity is Image)
     {
         client.DeleteImage(userId, token, (entity as Image).Id);
     }
     else if (entity is UserIdList)
     {
         client.DeleteUserIdList(userId, token, (entity as UserIdList).Application_Id, (entity as UserIdList).User_Id);
     }
     else if (entity is User)
     {
         client.DeleteUser(userId, token, (entity as User).Id);
     }
     else if (entity is UserApplicationInfo)
     {
         //delete the user instead
         //client.DeleteUserInfo(userId, token, (entity as UserApplicationInfo).User_Id, (entity as UserApplicationInfo).Application_Id);
         client.DeleteUser(userId, token, (entity as UserApplicationInfo).User_Id);
     }
     else if (entity is Room)
     {
         client.DeleteRoom(userId, token, (entity as Room).Id);
     }
     else if (entity is RoomGroup)
     {
         client.DeleteRoomGroup(userId, token, (entity as RoomGroup).Id);
     }
     else if (entity is Gift)
     {
         client.DeleteGift(userId, token, (entity as Gift).Id);
     }
     else if (entity is GiftGroup)
     {
         client.DeleteGiftGroup(userId, token, (entity as GiftGroup).Id);
     }
     else if (entity is DepositHistory)
     {
         client.DeleteDepositHistory(userId, token, (entity as DepositHistory).Id);
     }
     else if (entity is ExchangeHistory)
     {
         client.DeleteExchangeHistory(userId, token, (entity as ExchangeHistory).Id);
     }
     else if (entity is BlockList)
     {
         client.DeleteBlockList(userId, token, (entity as BlockList).Id);
     }
     else if (entity is BlockType)
     {
         client.DeleteBlockType(userId, token, (entity as BlockType).Id);
     }
     else if (entity is ExchangeRate)
     {
         client.DeleteExchangeRate(userId, token, (entity as ExchangeRate).Id);
     }
     else if (entity is RoomConfig)
     {
         client.DeleteRoomConfig(userId, token, (entity as RoomConfig).Id);
     }
 }