internal IFacadeUpdateResult <SubjectData> DeleteSubjectChildList(object parentId, object childId)
        {
            ArgumentValidator.IsNotNull("parentId", parentId);
            ArgumentValidator.IsNotNull("childId", childId);

            FacadeUpdateResult <SubjectData> result = new FacadeUpdateResult <SubjectData>();
            ISubjectService service = UnitOfWork.GetService <ISubjectService>();
            var             query   = service.Retrieve(parentId);

            if (query.HasResult)
            {
                Subject          parent = query.ToBo <Subject>();
                SubjectChildList child  = parent.SubjectChildLists.SingleOrDefault(o => object.Equals(o.Id, childId));
                if (child != null)
                {
                    parent.SubjectChildLists.Remove(child);
                    var saveQuery = parent.Save();
                    result.Merge(saveQuery);
                    result.AttachResult(parent.RetrieveData <SubjectData>());
                }
                else
                {
                    AddError(result.ValidationResult, "SubjectChildListCannotBeFound");
                }
            }
            else
            {
                AddError(result.ValidationResult, "SubjectCannotBeFound");
            }

            return(result);
        }
        internal SubjectChildList RetrieveOrNewSubjectChildList(Subject parent, object childId)
        {
            SubjectChildList child = null;

            if (childId != null)
            {
                child = parent.SubjectChildLists.SingleOrDefault(o => object.Equals(o.Id, childId));
            }
            else
            {
                child = parent.SubjectChildLists.AddNewBo();
            }

            return(child);
        }
        internal IFacadeUpdateResult <SubjectData> SaveSubjectChildList(object parentId, SubjectChildListDto childDto)
        {
            ArgumentValidator.IsNotNull("parentId", parentId);
            ArgumentValidator.IsNotNull("childDto", childDto);

            FacadeUpdateResult <SubjectData> result = new FacadeUpdateResult <SubjectData>();
            ISubjectService projectService          = UnitOfWork.GetService <ISubjectService>();
            var             projectQuery            = projectService.Retrieve(parentId);

            if (projectQuery.HasResult)
            {
                Subject          parent = projectQuery.ToBo <Subject>();
                SubjectChildList child  = RetrieveOrNewSubjectChildList(parent, childDto.Id);
                if (child != null)
                {
                    child.ChildListSubjectId = childDto.ChildListSubjectId;
                    child.Title          = childDto.Title;
                    child.AllowAdd       = childDto.AllowAdd;
                    child.AllowEdit      = childDto.AllowEdit;
                    child.AllowDelete    = childDto.AllowDelete;
                    child.AllowFiltering = childDto.AllowFiltering;
                    child.Sort           = childDto.Sort;
                    child.AllowImport    = childDto.AllowImport;
                    child.ImportUrl      = childDto.ImportUrl;

                    var saveQuery = projectService.Save(parent);
                    result.Merge(saveQuery);
                    result.AttachResult(parent.RetrieveData <SubjectData>());
                }
                else
                {
                    AddError(result.ValidationResult, "SubjectChildListCannotBeFound");
                }
            }

            return(result);
        }