Example #1
0
 protected void childList_InstanceRowSaving(object sender, InstanceRowSavingEventArgs e)
 {
     if (e.InstanceType == ChildListType.SubjectFieldInfo.ToString())
     {
         SubjectFieldInfoDto currentField         = e.Instance as SubjectFieldInfoDto;
         IFacadeUpdateResult <SubjectData> result = SaveSubjectField(CurrentSubject.Id, currentField);
         e.IsSuccessful = result.IsSuccessful;
         if (result.IsSuccessful)
         {
             // Refresh data in session
             RetrieveSubjectFieldInfos();
         }
         else
         {
             ProcUpdateResult(result.ValidationResult, result.Exception);
         }
     }
     else if (e.InstanceType == ChildListType.SubjectChildList.ToString())
     {
         SubjectChildListDto childList            = e.Instance as SubjectChildListDto;
         IFacadeUpdateResult <SubjectData> result = SaveSubjectChildList(CurrentSubject.Id, childList);
         e.IsSuccessful = result.IsSuccessful;
         if (result.IsSuccessful)
         {
             // Refresh data in session
             RetrieveSubject();
         }
         else
         {
             ProcUpdateResult(result.ValidationResult, result.Exception);
         }
     }
 }
Example #2
0
        private IFacadeUpdateResult <SubjectData> SaveSubjectChildList(object subjectId, SubjectChildListDto subjectChildList)
        {
            using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
            {
                SubjectFacade subjectFacade = new SubjectFacade(uow);
                IFacadeUpdateResult <SubjectData> result = subjectFacade.SaveSubjectChildList(subjectId, subjectChildList);

                return(result);
            }
        }
        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);
        }
        public IFacadeUpdateResult <SubjectData> SaveSubjectChildList(object parentId, SubjectChildListDto childDto)
        {
            UnitOfWork.BeginTransaction();
            IFacadeUpdateResult <SubjectData> result = SubjectSystem.SaveSubjectChildList(parentId, childDto);

            if (result.IsSuccessful)
            {
                UnitOfWork.CommitTransaction();
            }
            else
            {
                UnitOfWork.RollbackTransaction();
            }
            return(result);
        }