public void UpdateSection(int id, SectionSettingsViewModel newModel)
        {
            DoctrinaGroupSection section = _db.Find <DoctrinaGroupSection>(id);

            if (section != null)
            {
                if (!string.IsNullOrEmpty(newModel.NewName))
                {
                    section.Name = newModel.NewName;
                }

                _db.DoctrinaGroupSections.Attach(section);
                _db.Entry(section).State = EntityState.Modified;
                _db.SaveChanges();
            }
        }
        public void DeleteSection(int id)
        {
            DoctrinaGroupSection   section = _db.Find <DoctrinaGroupSection>(id);
            IList <DoctrinaScript> scripts = GetScripts(id);

            foreach (var script in scripts)
            {
                DeleteScript(script.Id);
            }

            string folderPath = Path.Combine(_hostingEnvironment.WebRootPath, $"DynamicResources/groups/{section.DoctrinaGroup.Id}/{section.Id}");

            Directory.Delete(folderPath);


            _db.Remove <DoctrinaGroupSection>(section);
            _db.SaveChanges();
        }
        public DoctrinaGroupSection CreateSection(CreateSectionViewModel model)
        {
            DoctrinaGroup currentGroup = this.GetGroup(model.GroupId);

            DoctrinaGroupSection newSection = new DoctrinaGroupSection
            {
                Name          = model.Name,
                DoctrinaGroup = currentGroup
            };

            _db.Add <DoctrinaGroupSection>(newSection);
            _db.SaveChanges();

            string folderPath = Path.Combine(_hostingEnvironment.WebRootPath, $"DynamicResources/groups/{currentGroup.Id}/{newSection.Id}");

            Directory.CreateDirectory(folderPath);

            return(newSection);
        }
        public DoctrinaGroupSection GetSection(int id)
        {
            DoctrinaGroupSection result = _db.DoctrinaGroupSections.Where(s => s.Id == id).FirstOrDefault();

            return(result);
        }