protected void Page_Load(object sender, EventArgs e)
		{
			Response.ContentType = "text/xml";

			try
			{
				CrossRef_AniDB_MALRepository repCrossRef = new CrossRef_AniDB_MALRepository();

				StreamReader reader = new StreamReader(this.Request.InputStream);
				String xmlData = reader.ReadToEnd();

				XmlDocument docXRef = new XmlDocument();
				docXRef.LoadXml(xmlData);

				string uname = Utils.TryGetProperty("DeleteCrossRef_AniDB_MALRequest", docXRef, "Username");

				string aid = Utils.TryGetProperty("DeleteCrossRef_AniDB_MALRequest", docXRef, "AnimeID");
				int animeid = 0;
				int.TryParse(aid, out animeid);

				string sepType = Utils.TryGetProperty("DeleteCrossRef_AniDB_MALRequest", docXRef, "StartEpisodeType");
				int epType = 0;
				int.TryParse(sepType, out epType);

				string sepNumber = Utils.TryGetProperty("DeleteCrossRef_AniDB_MALRequest", docXRef, "StartEpisodeNumber");
				int epNumber = 0;
				int.TryParse(sepNumber, out epNumber);

				if (string.IsNullOrEmpty(uname) || animeid <= 0 || epType <= 0 || epNumber <= 0)
				{
					Response.Write(Constants.ERROR_XML);
					return;
				}

				List<CrossRef_AniDB_MAL> recs = repCrossRef.GetByAnimeIDUser(animeid, uname, epType, epNumber);
				foreach (CrossRef_AniDB_MAL xref in recs)
				{
					repCrossRef.Delete(xref.CrossRef_AniDB_MALID);
				}

				// now send to mirror
				string uri = string.Format("http://{0}/DeleteCrossRef_AniDB_MAL.aspx", Constants.MirrorWAIX);
				XMLService.SendData(uri, xmlData);

			}
			catch (Exception ex)
			{
				Response.Write(Constants.ERROR_XML);
			}
		}
		protected void Page_Load(object sender, EventArgs e)
		{
			Response.ContentType = "text/xml";

			try
			{
				string aid = Utils.GetParam("AnimeID");
				int animeid = 0;
				int.TryParse(aid, out animeid);

				if (animeid <= 0)
				{
					Response.Write(Constants.ERROR_XML);
					return;
				}

				string uname = Utils.GetParam("uname");
				if (uname.Trim().Length == 0)
				{
					Response.Write(Constants.ERROR_XML);
					return;
				}

				CrossRef_AniDB_MALRepository repCrossRef = new CrossRef_AniDB_MALRepository();

				List<CrossRef_AniDB_MALResult> results = new List<CrossRef_AniDB_MALResult>();

				// check for user specific
				List<CrossRef_AniDB_MAL> recs = repCrossRef.GetByAnimeIDUser(animeid, uname);
				// check for other users
				if (recs.Count == 0)
				{
					// try user lwerndly
					recs = repCrossRef.GetByAnimeIDUser(animeid, "jonbaby");
					if (recs.Count == 0)
					{
						// try user jmediamanager
						recs = repCrossRef.GetByAnimeIDUser(animeid, "jmediamanager");
					}
				}

				if (recs.Count == 0)
				{
					Response.Write(Constants.ERROR_XML);
					return;
				}
				else
				{
					foreach (CrossRef_AniDB_MAL rec in recs)
					{
						CrossRef_AniDB_MALResult result = new CrossRef_AniDB_MALResult(rec);
						results.Add(result);
					}
					string ret = Utils.ConvertToXML(results, typeof(List<CrossRef_AniDB_MALResult>));
					Response.Write(ret);
				}
			}
			catch (Exception ex)
			{
				Response.Write(ex.ToString());
				return;
			}
		}
		protected void Page_Load(object sender, EventArgs e)
		{
			Response.ContentType = "text/xml";

			try
			{
				CrossRef_AniDB_MALRepository repCrossRef = new CrossRef_AniDB_MALRepository();

				StreamReader reader = new StreamReader(this.Request.InputStream);
				String xmlData = reader.ReadToEnd();

				XmlDocument docXRef = new XmlDocument();
				docXRef.LoadXml(xmlData);

				string uname = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "Username");
				string malTitle = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "MALTitle");

				string aid = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "AnimeID");
				int animeid = 0;
				int.TryParse(aid, out animeid);

				string mID = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "MALID");
				int malID = 0;
				int.TryParse(mID, out malID);

				string sepType = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "StartEpisodeType");
				int epType = 0;
				int.TryParse(sepType, out epType);

				string sepNumber = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "StartEpisodeNumber");
				int epNumber = 0;
				int.TryParse(sepNumber, out epNumber);


				if (string.IsNullOrEmpty(uname) || animeid <= 0 || malID <= 0 || epType <= 0 || epNumber <= 0)
				{
					Response.Write(Constants.ERROR_XML);
					return;
				}

				CrossRef_AniDB_MAL xref = null;
				List<CrossRef_AniDB_MAL> recs = repCrossRef.GetByAnimeIDUser(animeid, uname, epType, epNumber);
				if (recs.Count == 1)
					xref = recs[0];

				if (recs.Count == 0)
					xref = new CrossRef_AniDB_MAL();
				else
					xref = recs[0];

				xref.AnimeID = animeid;
				xref.CrossRefSource = 1;
				xref.MALID = malID;
				xref.MALTitle = malTitle;
				xref.Username = uname;
				xref.StartEpisodeType = epType;
				xref.StartEpisodeNumber = epNumber;
				repCrossRef.Save(xref);

				// now send to mirror
				string uri = string.Format("http://{0}/AddCrossRef_AniDB_MAL.aspx", Constants.MirrorWAIX);
				XMLService.SendData(uri, xmlData);

			}
			catch (Exception ex)
			{
				Response.Write(Constants.ERROR_XML);
			}
		}