Beispiel #1
0
        public static void loadcsmdata(csmdata csmdata)
        {
            // receive bndata, load to database
            using (LexileTitlesEntities lr = new LexileTitlesEntities())
            {
                List<CommonSenseMedia> existing = new List<CommonSenseMedia>(from c in lr.CommonSenseMedias
                                                                         where c.Isbn13 == csmdata.isbn13
                                                                         select c);

                if (existing.Count == 0)
                {
                    // create new BarnesAndNoble
                    CommonSenseMedia csm = new CommonSenseMedia();
                    csm.Isbn13 = csmdata.isbn13;
                    csm.url = csmdata.url;
                    csm.notforkids = csmdata.notforkids;
                    csm.offage = csmdata.offage;
                    csm.onage = csmdata.onage;
                    csm.review = csmdata.review;
                    csm.parentreview = csmdata.parentreview;
                    csm.kidreview = csmdata.kidreview;
                    csm.genre = csmdata.genre;

                    lr.CommonSenseMedias.Add(csm);
                    lr.SaveChanges();
                }
                else
                {
                    // update fields on existing BarnesAndNoble
                    existing[0].url = csmdata.url;
                    existing[0].notforkids = csmdata.notforkids;
                    existing[0].offage = csmdata.offage;
                    existing[0].onage = csmdata.onage;
                    existing[0].review = csmdata.review;
                    existing[0].parentreview = csmdata.parentreview;
                    existing[0].kidreview = csmdata.kidreview;
                    existing[0].genre = csmdata.genre;

                    lr.SaveChanges();
                }
            }
        }
        public static string loadcsmdata(csmdata csmdata)
        {
            string msg = "(DB LOADING ERROR)";
            // receive bndata, load to database

            try
            {
                using (LexileTitlesEntities lr = new LexileTitlesEntities())
                {
                    List<CommonSenseMedia> existing = new List<CommonSenseMedia>(from c in lr.CommonSenseMedias
                                                                                 where c.Isbn13 == csmdata.isbn13
                                                                                 select c);

                    if (existing.Count == 0)
                    {
                        // create new BarnesAndNoble
                        CommonSenseMedia csm = new CommonSenseMedia();
                        csm.Isbn13 = csmdata.isbn13;
                        csm.url = csmdata.url;
                        csm.notforkids = csmdata.notforkids;
                        csm.offage = csmdata.offage;
                        csm.onage = csmdata.onage;
                        csm.review = csmdata.review;
                        csm.parentreview = csmdata.parentreview;
                        csm.kidreview = csmdata.kidreview;
                        csm.genre = csmdata.genre;

                        lr.CommonSenseMedias.Add(csm);
                        lr.SaveChanges();

                        msg = "(Loaded new CSM to DB)";
                    }
                    else
                    {
                        // update fields on existing BarnesAndNoble
                        existing[0].url = csmdata.url;
                        existing[0].notforkids = csmdata.notforkids;
                        existing[0].offage = csmdata.offage;
                        existing[0].onage = csmdata.onage;
                        existing[0].review = csmdata.review;
                        existing[0].parentreview = csmdata.parentreview;
                        existing[0].kidreview = csmdata.kidreview;
                        existing[0].genre = csmdata.genre;

                        lr.SaveChanges();

                        msg = "(Updated existing CSM in DB)";
                    }
                }
            }
            catch { }

            return msg;
        }
Beispiel #3
0
 public static void appendcsm(CommonSenseMedia csm, TextWriter w)
 {
     w.WriteLine("{0}, {1}, {2}, {3}, {4}",
         string.Format("{0}", csm.Isbn13),
         string.Format("{0}", csm.url),
         string.Format("{0}", csm.notforkids),
         string.Format("{0}", csm.offage),
         string.Format("{0}", csm.onage));
 }