public void Save(AniDB_Anime_Review obj)
		{
			using (var session = JMMService.SessionFactory.OpenSession())
			{
				// populate the database
				using (var transaction = session.BeginTransaction())
				{
					session.SaveOrUpdate(obj);
					transaction.Commit();
				}
			}
		}
Exemple #2
0
        private void CreateAnimeReviews()
        {
            if (reviewIDListRAW != null)
            //Only create relations if the origin of the data if from Raw (WebService/AniDB)
            {
                if (reviewIDListRAW.Trim().Length == 0)
                    return;

                //Delete old if changed
                AniDB_Anime_ReviewRepository repReviews = new AniDB_Anime_ReviewRepository();
                List<AniDB_Anime_Review> animeReviews = repReviews.GetByAnimeID(AnimeID);
                foreach (AniDB_Anime_Review xref in animeReviews)
                {
                    repReviews.Delete(xref.AniDB_Anime_ReviewID);
                }

                string[] revs = reviewIDListRAW.Split(',');
                foreach (string review in revs)
                {
                    if (review.Trim().Length > 0)
                    {
                        int rev = 0;
                        Int32.TryParse(review.Trim(), out rev);
                        if (rev != 0)
                        {
                            AniDB_Anime_Review csr = new AniDB_Anime_Review();
                            csr.AnimeID = this.AnimeID;
                            csr.ReviewID = rev;
                            repReviews.Save(csr);
                        }
                    }
                }
            }
        }