In my Database I have Members Table and Pictures tables. A Member can have 1 to many Pictures. When Post has been made the member.Picture.Count = 0, I can't understand Why? and How should I solve this?
What Iam doing is:
public ActionResult Create()
{
Member member = new Member();
Picture pic = new Picture();
member.Pictures.add();
return View(new ClassifiedsFormViewModel(member));
}
//POST:
[AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Member member) {
if (ModelState.IsValid)
{
try
{
classifiedsRepository.Add(member);
classifiedsRepository.Save();
return RedirectToAction("Create", new { id = member.MemberId });
}
catch
{
ModelState.AddModelErrors(member.GetRuleViolations());
}
}
return View(new ClassifiedsFormViewModel(member));
}