Beispiel #1
0
        /// <summary>
        /// Converts from.
        /// </summary>
        /// <param name="importLog">The import log.</param>
        /// <param name="importLogFilesList">The import log files list.</param>
        /// <returns></returns>
        public FileImportLog ConvertFrom(EstateReporting.Database.Entities.FileImportLog importLog,
                                         List <FileImportLogFile> importLogFilesList)
        {
            FileImportLog model = new FileImportLog();

            model.FileImportLogId       = importLog.FileImportLogId;
            model.FileImportLogDateTime = importLog.ImportLogDateTime;
            model.EstateId = importLog.EstateId;
            model.Files    = new List <ImportLogFile>();

            IEnumerable <FileImportLogFile> currentImportLogFiles = importLogFilesList.Where(fi => fi.FileImportLogId == importLog.FileImportLogId);

            foreach (FileImportLogFile importLogFile in currentImportLogFiles)
            {
                model.Files.Add(new ImportLogFile
                {
                    MerchantId       = importLogFile.MerchantId,
                    EstateId         = importLogFile.EstateId,
                    FileId           = importLogFile.FileId,
                    FilePath         = importLogFile.FilePath,
                    FileProfileId    = importLogFile.FileProfileId,
                    OriginalFileName = importLogFile.OriginalFileName,
                    UserId           = importLogFile.UserId,
                    UploadedDateTime = importLogFile.FileUploadedDateTime
                });
            }

            return(model);
        }
Beispiel #2
0
        public void ModelFactory_ConvertFrom_FileImportLog_IsConverted()
        {
            FIleProcessor.Models.FileImportLog importLog = TestData.FileImportLogModel1;

            ModelFactory modelFactory = new ModelFactory();

            var result = modelFactory.ConvertFrom(importLog);

            this.VerifyFileImportLog(importLog, result);
        }
Beispiel #3
0
        private void VerifyFileImportLog(FIleProcessor.Models.FileImportLog source,
                                         DataTransferObjects.Responses.FileImportLog fileImportLog)
        {
            fileImportLog.ShouldNotBeNull();
            fileImportLog.Files.Count.ShouldBe(source.Files.Count);
            fileImportLog.ImportLogDateTime.ShouldBe(source.FileImportLogDateTime);

            foreach (ImportLogFile importLogFile in source.Files)
            {
                var foundFile = fileImportLog.Files.SingleOrDefault(f => f.FileId == importLogFile.FileId);
                foundFile.ShouldNotBeNull();
                foundFile.FileId.ShouldBe(importLogFile.FileId);
                foundFile.FileImportLogId.ShouldBe(fileImportLog.FileImportLogId);
                foundFile.MerchantId.ShouldBe(importLogFile.MerchantId);
                foundFile.OriginalFileName.ShouldBe(importLogFile.OriginalFileName);
                foundFile.FilePath.ShouldBe(importLogFile.FilePath);
                foundFile.FileProfileId.ShouldBe(importLogFile.FileProfileId);
                foundFile.FileUploadedDateTime.ShouldBe(importLogFile.UploadedDateTime);
                foundFile.UserId.ShouldBe(importLogFile.UserId);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Converts from.
        /// </summary>
        /// <param name="fileImportLog">The file import log.</param>
        /// <returns></returns>
        public FileImportLogResponse ConvertFrom(FileImportLog fileImportLog)
        {
            FileImportLogResponse fileImportLogResponse = new FileImportLogResponse
            {
                FileCount         = fileImportLog.Files.Count(),
                FileImportLogId   = fileImportLog.FileImportLogId,
                ImportLogDate     = fileImportLog.FileImportLogDateTime.Date,
                ImportLogDateTime = fileImportLog.FileImportLogDateTime,
                ImportLogTime     = fileImportLog.FileImportLogDateTime.TimeOfDay,
                Files             = new List <FileImportLogFile>()
            };

            foreach (ImportLogFile importLogFile in fileImportLog.Files)
            {
                FileImportLogFile fileImportLogFile = this.ConvertFrom(importLogFile);
                fileImportLogFile.FileImportLogId = fileImportLog.FileImportLogId;
                fileImportLogResponse.Files.Add(fileImportLogFile);
            }

            return(fileImportLogResponse);
        }
Beispiel #5
0
        private void VerifyImportLog(FileImportLog source, FIleProcessor.Models.FileImportLog importLog, Guid?merchantId = null)
        {
            importLog.ShouldNotBeNull();
            importLog.FileImportLogDateTime.ShouldBe(source.ImportLogDateTime);
            importLog.Files.Count.ShouldBe(importLog.Files.Count);

            List <ImportLogFile> filesToVerify = importLog.Files;

            if (merchantId.HasValue)
            {
                filesToVerify = filesToVerify.Where(f => f.MerchantId == merchantId.Value).ToList();
            }

            foreach (ImportLogFile importLogFile in filesToVerify)
            {
                var file = importLog.Files.SingleOrDefault(impfile => impfile.FileId == importLogFile.FileId);
                file.ShouldNotBeNull();
                file.MerchantId.ShouldBe(importLogFile.MerchantId);
                file.FilePath.ShouldBe(importLogFile.FilePath);
                file.FileProfileId.ShouldBe(importLogFile.FileProfileId);
                file.OriginalFileName.ShouldBe(importLogFile.OriginalFileName);
                file.UserId.ShouldBe(importLogFile.UserId);
            }
        }
        private void VerifyImportLog(EstateReporting.Database.Entities.FileImportLog sourceImportLog, List <FileImportLogFile> sourceFiles, FIleProcessor.Models.FileImportLog importLog)
        {
            importLog.ShouldNotBeNull();
            importLog.FileImportLogDateTime.ShouldBe(sourceImportLog.ImportLogDateTime);
            importLog.Files.Count.ShouldBe(sourceFiles.Count);

            foreach (var sourceFile in sourceFiles)
            {
                var file = importLog.Files.SingleOrDefault(impfile => impfile.FileId == sourceFile.FileId);
                file.ShouldNotBeNull();
                file.MerchantId.ShouldBe(sourceFile.MerchantId);
                file.FilePath.ShouldBe(sourceFile.FilePath);
                file.FileProfileId.ShouldBe(sourceFile.FileProfileId);
                file.OriginalFileName.ShouldBe(sourceFile.OriginalFileName);
                file.UserId.ShouldBe(sourceFile.UserId);
            }
        }