public void Save(CrossRef_AniDB_Other obj)
 {
     using (var session = WebCache.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(obj);
             transaction.Commit();
         }
     }
 }
Ejemplo n.º 2
0
		protected void Page_Load(object sender, EventArgs e)
		{
			Response.ContentType = "text/xml";

			try
			{
				CrossRef_AniDB_OtherRepository repCrossRef = new CrossRef_AniDB_OtherRepository();

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

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

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

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

				string xrefID = Utils.TryGetProperty("AddCrossRef_AniDB_Other_Request", docXRef, "CrossRefID");

				string xtype = Utils.TryGetProperty("AddCrossRef_AniDB_Other_Request", docXRef, "CrossRefType");
				int xrefType = 0;
				int.TryParse(xtype, out xrefType);




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

				CrossRef_AniDB_Other xref = null;
				List<CrossRef_AniDB_Other> recs = repCrossRef.GetByAnimeIDAndTypeAndUser(animeid, uname, (CrossRefType)xrefType);
				if (recs.Count == 1)
					xref = recs[0];

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

				xref.AnimeID = animeid;
				xref.AdminApproved = 0;
				xref.CrossRefSource = 1;
				xref.CrossRefType = xrefType;
				xref.CrossRefID = xrefID;
				xref.Username = uname;
				repCrossRef.Save(xref);

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

			}
			catch (Exception ex)
			{
				Response.Write(Constants.ERROR_XML);
			}
		}
Ejemplo n.º 3
0
		public CrossRef_AniDB_OtherResult(CrossRef_AniDB_Other xref)
		{
			this.AnimeID = xref.AnimeID;
			this.CrossRefID = xref.CrossRefID;
		}