title: Parse uploaded file, then save file contents to database and display to screen(webpage)
body: <p>I need to add an upload function. A component on the page that allows you to upload a file that has a list of movies and information about the movies then display it to screen (webpage) and save to a database.</p>
  
  <p>The part I need help with is parsing the contents of the uploaded csv file and saving the data to a sql server database and displaying the list of contents to the screen. I have created the upload function already see below:</p>
  
  <p>This is an ASP.NET MVC 4 movie application.</p>
  
  <p>Below is what I have so far:</p>
  
  <p>View:</p>
  
  <pre><code>@using (Html.BeginForm("Upload", "Movies", FormMethod.Post, new {enctype="multipart/form-data"}))
  {
      &lt;input type="file" name="File" id="File" /&gt;
      &lt;input type="submit" name="Submit"  value="Upload" /&gt;
      &lt;span&gt;@ViewBag.Message&lt;/span&gt;
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Upload(HttpPostedFileBase File )
  {
      // Verify that the user selected a file
      if (File != null &amp;&amp; File.ContentLength &gt; 0)
      {
          // extract only the filename
          var fileName = Path.GetFileName(File.FileName);
          // store the file inside ~/App_Data/uploads folder
          var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
          File.SaveAs(path);
          ViewBag.Message = "File uploaded successfully";
      }
  
      // redirect back to the index action to show the form once again
      return RedirectToAction("Index");
  }
  </code></pre>
  
  <p>Model (database):</p>
  
  <pre><code>public class Movie
  {
      public int ID { get; set; }
  
      [Required]
      public string Title { get; set; }
  
      //[DataType(DataType.Date)]
      public DateTime ReleaseDate { get; set; }
  
      [Required]
      public string Genre { get; set; }
  
      [Range(1,100)]
      [DataType(DataType.Currency)]
      public decimal Price { get; set; }
  
      public bool IsCompleted { get; set; }
  
      [StringLength(5)]
      public string Rating { get; set; }
  
      public string EnterUrl { get; set; }
  
      //public HttpPostedFileBase Document { get; set; }
  }
  
  public class MovieDBContext : DbContext
  {
      public DbSet&lt;Movie&gt; Movies { get; set; }
  }
  </code></pre>