public virtual UploadedFile ConvertPostedFile(Stream inputStream, string originalFileName)
        {
            if (inputStream == null)
            {
                throw new Exception("Null stream.");
            }

            if (!inputStream.CanRead)
            {
                throw new Exception("Can't read stream.");
            }

            var file = new UploadedFile()
            {
                OriginalFileName = originalFileName,
            };

            using (var sr = new StreamReader(inputStream))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    var lineItem = UploadedFile.CreateItemFromLine(line);
                    file.Lines.Add(lineItem);
                }
            }

            return file;
        }
 public virtual string GetFileAsCsv(UploadedFile file)
 {
     var sb = new StringBuilder();
     foreach (var lineItem in file.Lines)
     {
         sb.AppendLine(lineItem.AsCsv());
     }
     return sb.ToString();
 }