가 구매의도에 별도의 섹션을 만듭니다 복잡한 모델의
public class Transaction
{
[Key]
public int Id { get; set; }
public virtual PurchaseRequisition PurchaseRequisition { get; set; }
public virtual Evaluation Evaluation { get; set; }
}
등록 : 여기
복잡한 모델을 단순화 컨트롤러 여기
public class PurchaseRequisition
{
[Key, ForeignKey("Transaction")]
public int TransactionId { get; set; }
public virtual Transaction Transaction { get; set; }
[Display(Name = "Specifications/Requisitioner's Notes")]
public virtual ICollection<Attachment> SpecsRequisitionerNotesFiles { get; set; }
}
public class Evaluation
{
[Key, ForeignKey("Transaction")]
public int TransactionId { get; set; }
public virtual Transaction Transaction { get; set; }
public virtual ICollection<Attachment> BidResultsFiles { get; set; }
}
public abstract class Attachment
{
[Key]
public int Id { get; set; }
public string FileName { get; set; }
public string FileExtension { get; set; }
public byte[] Data { get; set; }
public Boolean Deleted { get; set; }
}
입니다 요청 및 입찰 결과. 이런 식으로 뭔가 :
<form action="" method="post" enctype="multipart/form-data">
<h3>Purchase Requistions</h3>
<label for="file1">Filename:</label>
<input type="file" name="purchasereqs" id="file1" />
<label for="file2">Filename:</label>
<input type="file" name="purchasereqs" id="file2" />
<h3>Bid Results</h3>
<label for="file3">Filename:</label>
<input type="file" name="bidresults" id="file3" />
<label for="file4">Filename:</label>
<input type="file" name="bidresults" id="file4" />
<input type="submit" />
</form>
는 그런 다음 작업 서명과 같은 것이다 : 완벽하게 작동
[HttpPost]
public ActionResult Create(
TransactionViewModel model,
IEnumerable<HttpPostedFileBase> purchasereqs,
IEnumerable<HttpPostedFileBase> bidresults)
{
//save to database
}
. 고맙습니다!! – ljustin