Exemple #1
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();
                }
            }
        }
Exemple #2
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;
        }
Exemple #6
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();
                }
            }
        }