Пример #1
0
        public static void getcsmdata(string isbn)
        {
            //create new TitleIsbn13 to pass to getscsmdata
            List<TitleIsbn13> ti13s = new List<TitleIsbn13>();

            TitleIsbn13 ti13 = new TitleIsbn13();
            ti13.isbn13 = isbn;

            bool exists = false;
            using (LexileTitlesEntities lr = new LexileTitlesEntities())
            {
                List<CommonSenseMedia> csms = new List<CommonSenseMedia>(from c in lr.CommonSenseMedias
                                                                         where c.Isbn13 == isbn
                                                                         select c);
                if (csms.Count > 0)
                {
                    // get title from LexileTitles
                    LexileTitle lex = (from l in lr.LexileTitles
                                       where l.Isbn13 == isbn
                                       select l).First();

                    ti13.title = lex.Title;

                    exists = true;

                }

            }

            if (exists)
            {
                ti13s.Add(ti13);

                getcsmdata(ti13s);
            }
        }
Пример #2
0
        public static void loadbndata(bndata bndata)
        {
            // receive bndata, load to database
            using (LexileTitlesEntities lr = new LexileTitlesEntities())
            {
                List<BarnesAndNoble> existing = new List<BarnesAndNoble>(from b in lr.BarnesAndNobles
                                                                         where b.Isbn13 == bndata.isbn13
                                                                         select b);

                if (existing.Count == 0)
                {
                    // create new BarnesAndNoble
                    BarnesAndNoble bn = new BarnesAndNoble();
                    bn.Isbn13 = bndata.isbn13;
                    bn.AgeHigh = bndata.agehigh;
                    bn.AgeLow = bndata.agelow;
                    bn.Rating = bndata.rating;

                    lr.BarnesAndNobles.Add(bn);
                    lr.SaveChanges();
                }
                else
                {
                    // update fields on existing BarnesAndNoble
                    existing[0].AgeHigh = bndata.agehigh;
                    existing[0].AgeLow = bndata.agelow;
                    existing[0].Rating = bndata.rating;

                    lr.SaveChanges();
                }
            }
        }
Пример #3
0
        public static void loadschdata(schdata schdata)
        {
            // receive schdata, load to database
            using (LexileTitlesEntities lr = new LexileTitlesEntities())
            {
                List<Scholastic> existing = new List<Scholastic>(from s in lr.Scholastics
                                                                         where s.Isbn13 == schdata.isbn13
                                                                         select s);

                if (existing.Count == 0)
                {
                    // create new BarnesAndNoble
                    Scholastic sch = new Scholastic();
                    sch.Isbn13 = schdata.isbn13;
                    sch.InterestLowGrade = schdata.interestlowgrade;
                    sch.InterestHighGrade = schdata.interesthighgrade;
                    sch.GradeEquiv = schdata.gradeequiv;
                    sch.DRA = schdata.dra;
                    sch.GuidedReading = schdata.guidedreading;
                    // genre TBD

                    lr.Scholastics.Add(sch);
                    lr.SaveChanges();
                }
                else
                {
                    // update fields on existing BarnesAndNoble

                    existing[0].InterestLowGrade = schdata.interestlowgrade;
                    existing[0].InterestHighGrade = schdata.interesthighgrade;
                    existing[0].GradeEquiv = schdata.gradeequiv;
                    existing[0].DRA = schdata.dra;
                    existing[0].GuidedReading = schdata.guidedreading;

                    lr.SaveChanges();
                }
            }
        }
        public static string loadschdata(ScholasticDto schdata)
        {
            string msg = "(Unable to load to local db)";
            // receive schdata, load to database

            UTF8Encoding enc = new System.Text.UTF8Encoding();
            byte[] bs = new byte[1]{(byte)schdata.ScholasticGradeHigher};

            try
            {
                using (LexileTitlesEntities lr = new LexileTitlesEntities())
                {
                    List<Scholastic> existing = new List<Scholastic>(from s in lr.Scholastics
                                                                     where s.Isbn13 == schdata.Isbn13
                                                                     select s);

                    if (existing.Count == 0)
                    {
                        // create new BarnesAndNoble
                        Scholastic sch = new Scholastic();
                        sch.Isbn13 = schdata.Isbn13;
                        sch.InterestLowGrade = schdata.ScholasticGradeLower;

                        sch.InterestHighGrade = enc.GetString(bs);
                        sch.GradeEquiv = (decimal)schdata.ScholasticGrade;
                        sch.DRA = schdata.Dra;
                        sch.GuidedReading = schdata.GuidedReading;
                        // genre TBD

                        lr.Scholastics.Add(sch);
                        lr.SaveChanges();

                        msg = "(Loaded new SCH to DB)";
                    }
                    else
                    {
                        // update fields on existing BarnesAndNoble

                        existing[0].InterestLowGrade = schdata.ScholasticGradeLower;
                        existing[0].InterestHighGrade = enc.GetString(bs);
                        existing[0].GradeEquiv = (decimal)schdata.ScholasticGrade;
                        existing[0].DRA = schdata.Dra;
                        existing[0].GuidedReading = schdata.GuidedReading;

                        lr.SaveChanges();

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

            return msg;
        }
        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;
        }
        public static string loadbndata(BarnesDto bndata)
        {
            string msg = "(Unable to load to local db)";
            // receive bndata, load to database
            try
            {
                using (LexileTitlesEntities lr = new LexileTitlesEntities())
                {
                    List<BarnesAndNoble> existing = new List<BarnesAndNoble>(from b in lr.BarnesAndNobles
                                                                             where b.Isbn13 == bndata.Isbn13
                                                                             select b);

                    if (existing.Count == 0)
                    {
                        // create new BarnesAndNoble
                        BarnesAndNoble bn = new BarnesAndNoble();
                        bn.Isbn13 = bndata.Isbn13;
                        bn.AgeHigh = bndata.BarnesAgeOld;
                        bn.AgeLow = bndata.BarnesAgeYoung;
                        bn.Rating = (decimal)bndata.BarnesAvg;

                        lr.BarnesAndNobles.Add(bn);
                        lr.SaveChanges();

                        msg = "(Loaded new BN to DB)";
                    }
                    else
                    {
                        // update fields on existing BarnesAndNoble
                        existing[0].AgeHigh = bndata.BarnesAgeOld;
                        existing[0].AgeLow = bndata.BarnesAgeYoung;
                        existing[0].Rating = (decimal)bndata.BarnesAvg;

                        lr.SaveChanges();

                        msg = "(Updated existing BN in DB)";
                    }
                }
            }

            catch { }

            return msg;
        }
        public ActionResult TestResult()
        {
            LexileTitlesEntities lte = new LexileTitlesEntities();
            // get some info from database, call LexileTitles
            List<LexileTitle> testlist = new List<LexileTitle>(
                (from lt in lte.LexileTitles
                 select lt).Take(2));

            // call service function
            // List<byte[]> resultlist = BookCaveSvc.PostNewLexile(testlist);

            List<StandardResult> resultlist = BookCaveSvc.postNewLexile(testlist);

            ViewBag.ResultList = resultlist;

            return View();
        }
        public ActionResult testCommonSense()
        {
            LexileTitlesEntities lte = new LexileTitlesEntities();
            // get some info from database, call LexileTitles
            List<LexileTitle> lexs = new List<LexileTitle>(
                (from lt in lte.LexileTitles
                 where lt.Awards != null
                 select lt).Take(20));

            // 'acquire' CSM record
            List<TitleIsbn13> TitleIsbns = new List<TitleIsbn13>();

            foreach (LexileTitle lex in lexs)
            {
                TitleIsbn13 ti = new TitleIsbn13();
                ti.isbn13 = lex.Isbn13;
                ti.title = lex.Title;

                TitleIsbns.Add(ti);

            }

            List<StandardResult> resultlist = DataAcquisition.getcsmdata(TitleIsbns, "loaddb");

            ViewBag.ResultList = resultlist;

            return View();
        }
Пример #9
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();
                }
            }
        }