using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using BLL;
using Model;
using Helper;
using System.Data;
namespace WEBAPI
{
    public partial class search : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<Music> list = new List<Music>();
            try
            {
                MusicBLL bll = new MusicBLL(Request["source"]);
                string word = Request["word"];
                int page = Convert.ToInt32(Request["page"]);
                int num = Convert.ToInt32(Request["num"]);
                list.AddRange(bll.Search(word, page, num));
            }
            catch (Exception ex)
            {
                Music m = new Music();
                m.Name = ex.Message;
                m.Artist = ex.GetType().ToString();
                m.Album = ex.TargetSite.ToString();
                list.Add(m);
            }
            //Response.Write(Convert.ToBase64String(ConvertEx.Object2Bytes(list)));
            Response.Write(Music.ListToJson(list));
            //List<Music> result = Music.JsonToList(Music.ListToJson(list));
            //Console.WriteLine(result);
        }
    }
}