Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. [HttpPost]
  2. [ValidateAntiForgeryToken]
  3. [AllowAnonymous]
  4. public ActionResult Create(Station station)
  5. {
  6. station.FileName = station.File.FileName;
  7. station.ImageSize = station.File.ContentLength;
  8. byte[] data = new byte[station.File.ContentLength];
  9. station.File.InputStream.Read(data, 0, station.File.ContentLength);
  10. station.ImageData = data;
  11.  
  12. db.Stations.Add(station);
  13. db.SaveChanges();
  14.  
  15. return RedirectToAction("Index");
  16. }
  17.  
  18. public class Station
  19. {
  20. [Key]
  21. public int Id { get; set; }
  22. [Display(Name="Station Name")]
  23. public string StationName { get; set; }
  24. public double Distance { get; set; }
  25. [DataType(DataType.PhoneNumber)]
  26. public string Mobile { get; set; }
  27. [DataType(DataType.Date)]
  28. public DateTime Opening { get; set; }
  29. public string Connections { get; set; }
  30. public string Layout { get; set; }
  31. [Display(Name="Tourists Place")]
  32. public string TouristsPlace { get; set; }
  33. [Display(Name = "Tourists Place Image")]
  34. /////////
  35. public int ImageId { get; set; }
  36. public Nullable<int> ImageSize { get; set; }
  37. public string FileName { get; set; }
  38. public byte[] ImageData { get; set; }
  39.  
  40. [Required(ErrorMessage = "Please select file")]
  41. public HttpPostedFileBase File { get; set; }
  42. /// <summary>
  43. /// ////
  44. /// </summary>
  45. [Display(Name="Line Color")]
  46. public string LineColor { get; set; }
  47. }
  48.  
  49. [NotMapped]
  50. public HttpPostedFileBase File { get; set; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement