Example #1
0
        public string Put(SubSectionModel subSectionModel)
        {
            string success = "";

            try
            {
                using (var db = new BookDbContext())
                {
                    var bookSubSection = db.SubSections.Where(s => s.Id == subSectionModel.Id).FirstOrDefault();
                    if (bookSubSection == null)
                    {
                        success = "not found";
                    }
                    else
                    {
                        bookSubSection.SubSectionTitle    = subSectionModel.SubSectionTitle;
                        bookSubSection.SubSectionOrder    = subSectionModel.SubSectionOrder;
                        bookSubSection.SubSectionContents = subSectionModel.SubSectionContents;
                        db.SaveChanges();
                        success = "ok";
                    }
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
Example #2
0
        public SubSectionModel Patch(int subSectionId)
        {
            var subSectionModel = new SubSectionModel();

            using (var db = new BookDbContext())
            {
                var dbSubSection = db.SubSections.Where(s => s.Id == subSectionId).FirstOrDefault();
                if (dbSubSection != null)
                {
                    subSectionModel.Id = dbSubSection.Id;
                    subSectionModel.SubSectionTitle    = dbSubSection.SubSectionTitle;
                    subSectionModel.SubSectionOrder    = dbSubSection.SubSectionOrder;
                    subSectionModel.SubSectionContents = dbSubSection.SubSectionContents;

                    //subSection.v
                    subSectionModel.SectionTitle = dbSubSection.BookSection.SectionTitle;
                    subSectionModel.SectionOrder = dbSubSection.BookSection.SectionOrder;
                    subSectionModel.ChapterTitle = dbSubSection.BookSection.Chapter.ChapterTitle;
                    subSectionModel.ChapterOrder = dbSubSection.BookSection.Chapter.ChapterOrder;

                    subSectionModel.SectionId = dbSubSection.SectionId.Value;
                    subSectionModel.success   = "ok";
                }
            }
            return(subSectionModel);
        }
Example #3
0
        public ActionResult Index()
        {
            AdminModel model = new AdminModel();

            model.brands = new List <BrandModel>();
            foreach (var brand in setzDB.Brands)
            {
                BrandModel brandModel = new BrandModel();
                brandModel.brand = brand;
                model.brands.Add(brandModel);
            }

            model.sectionModels = new List <SectionModel>();
            foreach (var section in setzDB.Sections.OrderBy(s => s.Order))
            {
                SectionModel sectionModel = new SectionModel();
                sectionModel.section          = section;
                sectionModel.subSectionModels = new List <SubSectionModel>();
                foreach (var subSection in setzDB.SubSections.Where(subs => subs.SectionID == section.ID).OrderBy(ss => ss.Order))
                {
                    SubSectionModel subSectionModel = new SubSectionModel();
                    subSectionModel.subSection     = subSection;
                    subSectionModel.categoryModels = new List <CategoryModel>();

                    foreach (var category in setzDB.Categories.Where(a => a.SubSectionID == subSection.ID).OrderBy(c => c.Order))
                    {
                        CategoryModel categoryModel = new CategoryModel();
                        categoryModel.category      = category;
                        categoryModel.subCategories = new List <SubCategory>();
                        foreach (var subCategory in setzDB.SubCategories.Where(b => b.CategoryID == category.ID).OrderBy(sc => sc.Order))
                        {
                            categoryModel.subCategories.Add(subCategory);
                        }
                        subSectionModel.categoryModels.Add(categoryModel);
                    }
                    sectionModel.subSectionModels.Add(subSectionModel);
                }
                model.sectionModels.Add(sectionModel);
            }
            return(View(model));
        }
Example #4
0
        public string Post(SubSectionModel subSectionModel)
        {
            string success = "";

            try
            {
                using (var db = new BookDbContext())
                {
                    var bookSubSection = new SubSection()
                    {
                        SectionId          = subSectionModel.SectionId,
                        Id                 = subSectionModel.Id,
                        SubSectionTitle    = subSectionModel.SubSectionTitle,
                        SubSectionOrder    = subSectionModel.SubSectionOrder,
                        SubSectionContents = subSectionModel.SubSectionContents,
                    };
                    db.SubSections.Add(bookSubSection);
                    db.SaveChanges();
                    success = bookSubSection.Id.ToString();
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
Example #5
0
        public List <SectionModel> generateNavBar()
        {
            List <SectionModel> sectionModelList = new List <SectionModel>();

            foreach (var section in setzDB.Sections.OrderBy(s => s.Order))
            {
                if (section.Visibility)
                {
                    SectionModel sectionModel = new SectionModel();
                    sectionModel.section          = section;
                    sectionModel.subSectionModels = new List <SubSectionModel>();
                    foreach (var subSection in setzDB.SubSections.Where(subs => subs.SectionID == section.ID).OrderBy(ss => ss.Order))
                    {
                        if (subSection.Visibility)
                        {
                            SubSectionModel subSectionModel = new SubSectionModel();
                            subSectionModel.subSection     = subSection;
                            subSectionModel.categoryModels = new List <CategoryModel>();
                            foreach (var category in setzDB.Categories.Where(c => c.SubSectionID == subSection.ID).OrderBy(c => c.Order))
                            {
                                if (category.Visibility)
                                {
                                    CategoryModel categoryModel = new CategoryModel();
                                    categoryModel.category = category;
                                    //categoryModel.subCategories = setzDB.SubCategories.Where(s => s.CategoryID == category.ID).ToList();
                                    subSectionModel.categoryModels.Add(categoryModel);
                                }
                            }
                            sectionModel.subSectionModels.Add(subSectionModel);
                        }
                    }
                    sectionModelList.Add(sectionModel);
                }
            }
            return(sectionModelList);
        }
Example #6
0
 public SectionDataModel(SubSectionModel obj)
 {
     SubSections = new List <SubSectionModel>();
     SubSections.Add(obj);
 }