コード例 #1
0
        public static void UpdateFrom(this SoaChapter dbSoaChapter, Contracts.Soa.SoaChapter soaChapter, string isoCode)
        {
            var dbSoaChapterItem = dbSoaChapter.SoaChapterItems.FirstOrDefault(i => i.IsoCode == isoCode);

            if (dbSoaChapterItem == null)
            {
                dbSoaChapterItem = new SoaChapterItem();
                dbSoaChapter.SoaChapterItems.Add(dbSoaChapterItem);
            }
            dbSoaChapterItem.Name        = soaChapter.Name;
            dbSoaChapterItem.Description = soaChapter.Description;
            dbSoaChapterItem.Goal        = soaChapter.Goal;
            dbSoaChapterItem.HowTo       = soaChapter.HowTo;
            dbSoaChapterItem.Info        = soaChapter.Info;
        }
コード例 #2
0
        public static SoaChapter ToDataModel(this Contracts.Soa.SoaChapter soaChapter, SoaChapter parentSoaChapter, RAAPMasterEntities db, string isoCode)
        {
            var dbSoaChapter = new SoaChapter()
            {
                ParentChapter = parentSoaChapter,
                SoaType       = soaChapter.SoaType,
            };
            var dbSoaChapterItem = new SoaChapterItem()
            {
                Name        = soaChapter.Name,
                Description = soaChapter.Description,
                Goal        = soaChapter.Goal,
                HowTo       = soaChapter.HowTo,
                Info        = soaChapter.Info,
                IsoCode     = isoCode,
            };

            dbSoaChapter.SoaChapterItems.Add(dbSoaChapterItem);
            //db.SaveChanges(); //<-not optimal, but need to save parent chapters to make recursive linking work... :/
            soaChapter.SubChapters.ForEach(c => c.ToDataModel(dbSoaChapter, db, isoCode));
            return(dbSoaChapter);
        }