public SubsiteBatchFacade(IUnitOfWork unitOfWork)
     : base(unitOfWork)
 {
     FolderSystem       = new FolderSystem(unitOfWork);
     SubsiteSystem      = new SubsiteSystem(unitOfWork);
     ReferenceSystem    = new ReferenceSystem(unitOfWork);
     SubitemValueSystem = new SubitemValueSystem(UnitOfWork);
 }
        public IFacadeUpdateResult <ReferenceData> SaveReferenceInWhole(ReferenceData dto)
        {
            UnitOfWork.BeginTransaction();
            // 1. Save Reference itself
            FacadeUpdateResult <ReferenceData> result = ReferenceSystem.SaveReference(dto);

            if (result.IsSuccessful)
            {
                object referenceId = result.Result.Id;
                // 2. Save ReferenceKeywords
                IFacadeUpdateResult <ReferenceData> result2 = ReferenceSystem.SaveReferenceKeywords(referenceId, dto.ReferenceKeywords);
                if (result2.IsSuccessful)
                {
                    // 3. Save SubitemValues
                    SubitemValueSystem subitemValueSystem       = new SubitemValueSystem(UnitOfWork);
                    IFacadeUpdateResult <ReferenceData> result3 = subitemValueSystem.SaveSubitemValues(referenceId, dto.Values);
                    if (result3.IsSuccessful)
                    {
                        foreach (GridRowData row in dto.GridRows)
                        {
                            row.ReferenceId = referenceId;
                            IFacadeUpdateResult <GridRowData> result4 = ReferenceSystem.SaveGridRow(row);
                            if (!result4.IsSuccessful)
                            {
                                result.ValidationResult.Merge(result4.ValidationResult);
                            }
                        }
                    }
                    else
                    {
                        result.ValidationResult.Merge(result3.ValidationResult);
                    }
                }
                else
                {
                    result.ValidationResult.Merge(result2.ValidationResult);
                }
            }
            // Commit or Rollback
            if (result.IsSuccessful)
            {
                UnitOfWork.CommitTransaction();
            }
            else
            {
                UnitOfWork.RollbackTransaction();
            }

            return(result);
        }
        public IFacadeUpdateResult <ReferenceData> SaveReferenceValueLanguages(IList <SubitemValueData> values, object languageId)
        {
            SubitemValueSystem subitemValueSystem = new SubitemValueSystem(UnitOfWork);

            UnitOfWork.BeginTransaction();
            IFacadeUpdateResult <ReferenceData> result = subitemValueSystem.SaveSubitemValueLanguages(values, languageId);

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

            return(result);
        }
 public SubitemValueFacade(IUnitOfWork unitOfWork)
     : base(unitOfWork)
 {
     SubitemValueSystem = new SubitemValueSystem(unitOfWork);
 }