public static ParticipantInformationViewModel Map(this ParticipantInformationDto entity)
 {
     return(new ParticipantInformationViewModel()
     {
         Document = entity.Document,
         File = entity.FileInfo,
     });
 }
 public static TraceabilityEntity Map(this ParticipantInformationDto entity)
 {
     return(new TraceabilityEntity()
     {
         CreationDate = DateTime.Now,
         Document = entity.Document,
         TraceabilityId = Guid.NewGuid(),
     });
 }
Example #3
0
        /// <summary>
        /// Process information
        /// </summary>
        /// <param name="participantInformationDto"></param>
        /// <returns></returns>
        public async Task <FileStreamResult> Process(ParticipantInformationDto participantInformationDto)
        {
            await _traceabilityRepository.AddAsync(participantInformationDto.Map());

            MemoryStream resultProcess = await FileProcess(participantInformationDto);

            var result = new FileStreamResult(resultProcess, "text/plain")
            {
                FileDownloadName = CommonInformation.FileOutPut
            };

            return(result);
        }
        /// <summary>
        /// Process file
        /// </summary>
        /// <param name="formFile"></param>
        /// <returns></returns>
        public async Task <MemoryStream> FileProcess(ParticipantInformationDto participantInformationDto)
        {
            List <int> lstInformationFile = new List <int>();

            await ReadAsStringAsync(participantInformationDto.FileInfo, lstInformationFile);

            List <string> lstResult = new List <string>();

            ValidateInformation(lstInformationFile, lstResult);
            StringBuilder strResultBuilder = new StringBuilder();

            lstResult.ForEach(item => strResultBuilder.AppendLine(item));
            return(new MemoryStream(Encoding.UTF8.GetBytes(strResultBuilder?.ToString())));
        }