public void Save(AniDB_Recommendation obj)
		{
			using (var session = JMMService.SessionFactory.OpenSession())
			{
				// populate the database
				using (var transaction = session.BeginTransaction())
				{
					session.SaveOrUpdate(obj);
					transaction.Commit();
				}
			}
		}
예제 #2
0
        private void CreateRecommendations(ISession session, List<Raw_AniDB_Recommendation> recs)
        {
            if (recs == null) return;

            //AniDB_RecommendationRepository repRecs = new AniDB_RecommendationRepository();

            List<AniDB_Recommendation> recsToSave = new List<AniDB_Recommendation>();

            foreach (Raw_AniDB_Recommendation rawRec in recs)
            {
                AniDB_Recommendation rec = session
                    .CreateCriteria(typeof(AniDB_Recommendation))
                    .Add(Restrictions.Eq("AnimeID", rawRec.AnimeID))
                    .Add(Restrictions.Eq("UserID", rawRec.UserID))
                    .UniqueResult<AniDB_Recommendation>();

                if (rec == null)
                    rec = new AniDB_Recommendation();
                rec.Populate(rawRec);
                recsToSave.Add(rec);
            }

            using (var transaction = session.BeginTransaction())
            {
                foreach (AniDB_Recommendation rec in recsToSave)
                    session.SaveOrUpdate(rec);

                transaction.Commit();
            }
        }
예제 #3
0
        private void CreateRecommendations(ISession session, List<Raw_AniDB_Recommendation> recs)
        {
            if (recs == null) return;

            //AniDB_RecommendationRepository repRecs = new AniDB_RecommendationRepository();

            List<AniDB_Recommendation> recsToSave = new List<AniDB_Recommendation>();
            foreach (Raw_AniDB_Recommendation rawRec in recs)
            {
                AniDB_Recommendation rec = RepoFactory.AniDB_Recommendation.GetByAnimeIDAndUserID(session, rawRec.AnimeID, rawRec.UserID);
                if (rec == null)
                    rec = new AniDB_Recommendation();
                rec.Populate(rawRec);
                recsToSave.Add(rec);
            }
            RepoFactory.AniDB_Recommendation.Save(recsToSave);
        }