using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using JuSNS.Model;

namespace JuSNS.Web.inc.ajax
{
    public partial class friend : JuSNS.UI.Page.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            if (this.GetUserID() == 0)
            {
                Response.Write("err");
                Response.End();
            }
            if (Request.Form["Option"] != null)
            {
                JuSNS.Home.Friend fnd = new JuSNS.Home.Friend();
                string opt = Request.Form["Option"];
                try
                {
                    switch (opt)
                    {
                        case "Greet":
                            fnd.Greet(this.GetUserID(), int.Parse(Request.Form["FriendID"]));
                            Response.Write("1");
                            //&FriendID="+ uid,
                            break;
                        case "Delete":
                            fnd.Diffidation(this.GetUserID(), int.Parse(Request.Form["FriendID"]));
                            Response.Write("1");
                            //&FriendID="+ uid,
                            break;
                        case "ApplyFrd":
                            fnd.Request(this.GetUserID(), int.Parse(Request.Form["FriendID"]));
                            Response.Write("1");
                            break;
                        case "Accept":
                            fnd.Response(this.GetUserID(), int.Parse(Request.Form["RID"]), EnumReply.Agree, Request.Form["ClassID"]);
                            Response.Write("1");
                            break;
                        case "Refuse":
                            fnd.Response(this.GetUserID(), int.Parse(Request.Form["RID"]), EnumReply.Decline, string.Empty);
                            Response.Write("1");
                            break;
                    }
                }
                catch
                {
                    Response.Write("0");
                }
            }
            Response.End();
        }
        //}
    }
}
