Guest User

Untitled

a guest
Nov 18th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. public ActionResult Edit(int id)
  2. {
  3. var e = db.Files.Find(id);
  4. var vm = new ClientInfoVM() { ClientID = id, FileName = e.FileName };
  5. vm.Content = e.Content;
  6.  
  7. if (e.Content != null)
  8. {
  9. vm.Content = $"data:image/jpg;base64,{Convert.ToBase64String(e.Content)}";
  10. }
  11.  
  12. public partial class client__information
  13. {
  14. [Key]
  15. public int ClientID { get; set; }
  16.  
  17. public long AccountNumber { get; set; }
  18.  
  19. [Required]
  20. [StringLength(30)]
  21. public string FirstName { get; set; }
  22.  
  23. [StringLength(30)]
  24. public string MiddleName { get; set; }
  25.  
  26. [Required]
  27. [StringLength(30)]
  28. public string LastName { get; set; }
  29.  
  30. [StringLength(30)]
  31. public string NickName { get; set; }
  32.  
  33. [Column(TypeName = "date")]
  34. [DataType(DataType.Date)]
  35. public DateTime DOB { get; set; }
  36.  
  37. public int? GenderTypeID { get; set; }
  38. [ForeignKey("GenderTypeID")]
  39. public virtual data__gender_codes Gender { get; set; }
  40.  
  41. [ForeignKey("LocationID")]
  42. public long? FacilityID { get; set; }
  43. public virtual facility__information__location__names LocationID { get; set; }
  44.  
  45. public long? StatusID { get; set; }
  46. [ForeignKey("StatusID")]
  47. public virtual client__information__status__codes SID { get; set; }
  48.  
  49. [Column(TypeName = "date")]
  50. public DateTime StartDate { get; set; }
  51.  
  52. public int StartTimeID { get; set; }
  53. [ForeignKey("StartTimeID")]
  54. public virtual data__start_times STID { get; set; }
  55.  
  56. [Column(TypeName = "date")]
  57. public DateTime? EndDate { get; set; }
  58.  
  59. public byte? EndTime { get; set; }
  60.  
  61. public long ResponsiblePartyID { get; set; }
  62.  
  63. public DateTime DateAdded { get; set; }
  64.  
  65. public long AddedBy { get; set; }
  66.  
  67. public DateTime DateChanged { get; set; }
  68.  
  69. public int? ChangedBy { get; set; }
  70.  
  71. [Column(TypeName = "date")]
  72. public DateTime? DestroyDate { get; set; }
  73.  
  74. public virtual ICollection<File> Files { get; set; }
  75.  
  76. }
  77.  
  78. public class File
  79. {
  80. public int FileId { get; set; }
  81. [StringLength(255)]
  82. public string FileName { get; set; }
  83. [StringLength(100)]
  84. public string ContentType { get; set; }
  85. public byte[] Content { get; set; }
  86. public FileType FileType { get; set; }
  87. public int UserId { get; set; }
  88. public virtual client__information Client__Information { get; set; }
  89. }
  90.  
  91. public class ClientInfoVM
  92. {
  93. //client__information Model
  94. public int ClientID { get; set; }
  95. public long AccountNumber { get; set; }
  96. public string FirstName { get; set; }
  97. public string MiddleName { get; set; }
  98. public string LastName { get; set; }
  99. public string NickName { get; set; }
  100. public DateTime DOB { get; set; }
  101. public int? GenderTypeID { get; set; }
  102. public long? FacilityID { get; set; }
  103. public long? StatusID { get; set; }
  104. public DateTime StartDate { get; set; }
  105. public int StartTimeID { get; set; }
  106. public DateTime? EndDate { get; set; }
  107. public byte? EndTime { get; set; }
  108. public long ResponsiblePartyID { get; set; }
  109. public long AddedBy { get; set; }
  110. public DateTime DateChanged { get; set; }
  111. public int? ChangedBy { get; set; }
  112. public DateTime? DestroyDate { get; set; }
  113. public virtual ICollection<File> Files { get; set; }
  114.  
  115. //File Model
  116. public string FileName { get; set; }
  117. public HttpPostedFileBase Content { get; set; }
  118. public int FileId { get; set; }
  119. public string ContentType { get; set; }
  120. public FileType FileType { get; set; }
  121.  
  122.  
  123. }
  124.  
  125. "cannot implicitly convert type 'string' to 'System.Web.HttpPostedFileBase"
Add Comment
Please, Sign In to add comment