Convert() public method

public Convert ( Array, values, Type, targetType, object parameter, CultureInfo, culture ) : object
values Array,
targetType Type,
parameter object
culture CultureInfo,
return object
Example #1
0
        public void OnPost()
        {
            var payees = payeeRepository.GetAll();

            var input = new StringBuilder();

            using (var reader = new StreamReader(FormFile.OpenReadStream(), Encoding.GetEncoding("ISO-8859-1")))
            {
                while (reader.Peek() >= 0)
                {
                    input.AppendLine(reader.ReadLine());
                }
            }

            var inputRecords  = MyConverter.GetInputRecords(input.ToString());
            var outputRecords = new List <Output>();

            foreach (var record in inputRecords)
            {
                outputRecords.Add(MyConverter.Convert(record, payees));
            }

            InputRecords.AddRange(inputRecords);
            OutputRecords.AddRange(outputRecords);
            Output = MyConverter.GetOutputString(outputRecords);
        }
        public IActionResult Index(IFormFile file)
        {
            var payees = repository.GetAll();

            var input = new StringBuilder();

            using (var reader = new StreamReader(file.OpenReadStream(), Encoding.GetEncoding("ISO-8859-1")))
            {
                while (reader.Peek() >= 0)
                {
                    input.AppendLine(reader.ReadLine());
                }
            }

            var inputRecords  = MyConverter.GetInputRecords(input.ToString());
            var outputRecords = new List <Output>();

            foreach (var record in inputRecords)
            {
                outputRecords.Add(MyConverter.Convert(record, payees));
            }
            var output = MyConverter.GetOutputString(outputRecords);

            var model = new HomeViewModel();

            model.InputRecords.AddRange(inputRecords);
            model.OutputRecords.AddRange(outputRecords);
            model.Output = output;
            return(View(model));
        }