Пример #1
0
        internal TDto RetrieveOrNewDataPhrase <TDto>(object instanceId, IDataConverter <DataPhraseData, TDto> converter)
            where TDto : class
        {
            ArgumentValidator.IsNotNull("converter", converter);
            IDataPhraseService service = UnitOfWork.GetService <IDataPhraseService>();
            FacadeUpdateResult <DataPhraseData> result = new FacadeUpdateResult <DataPhraseData>();
            DataPhrase instance = RetrieveOrNew <DataPhraseData, DataPhrase, IDataPhraseService>(result.ValidationResult, instanceId);

            if (result.IsSuccessful)
            {
                return(converter.Convert(instance.RetrieveData <DataPhraseData>()));
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        internal IFacadeUpdateResult <DataPhraseData> SaveDataPhrase(DataPhraseDto dto)
        {
            ArgumentValidator.IsNotNull("dto", dto);

            FacadeUpdateResult <DataPhraseData> result = new FacadeUpdateResult <DataPhraseData>();
            IDataPhraseService service  = UnitOfWork.GetService <IDataPhraseService>();
            DataPhrase         instance = RetrieveOrNew <DataPhraseData, DataPhrase, IDataPhraseService>(result.ValidationResult, dto.Id);

            if (result.IsSuccessful)
            {
                instance.LanguageId  = dto.LanguageId;
                instance.PhraseKey   = dto.PhraseKey;
                instance.PhraseValue = dto.PhraseValue;

                var saveQuery = service.Save(instance);

                result.AttachResult(instance.RetrieveData <DataPhraseData>());
                result.Merge(saveQuery);
            }

            return(result);
        }