0

我有一个带有 3 个步骤/3 个视图的向导,每个视图都有自己的 ViewModel,我需要插入一个提交来自 3 个视图的所有信息。

所有视图都包含在使用 Html.RenderAction 方法的主视图中。

@:<!--- Step1 --->
<div class="company-add-step5-elements-container">@{ Html.RenderAction(MVC.Company.CreateS1NameAddress()); }</div>

@:<!--- Step2 --->
<div class="company-add-step2-elements-container">@{ Html.RenderAction(MVC.Company.CreateS2Services()); }</div>

@:<!--- Step3 --->
<div class="company-add-step3-elements-container">@{ Html.RenderAction(MVC.Company.CreateS3Schedule()); }</div>

第 1 步的 ViewModel:

// Primary properties
[Required(ErrorMessageResourceName = "ErrorMsgRequiredField", ErrorMessageResourceType = typeof(HeelpResources))]
public string CompanyName { get; set; }

public string Telephone { get; set; }

Step2 的 ViewModel:

[Display(ResourceType = typeof(HeelpResources), Name = "AddressViewModelAddressLabel")]
public string Address1 { get; set; }

public string Address2 { get; set; }

Step3 的 ViewModel:

[Display(ResourceType = typeof(HeelpResources), Name = "AddressViewModelCityLabel")]
public string City { get; set; }

现在如何创建一个 ViewModel 来提交所有步骤:

public class CompanyCreateViewModel
{
    // How can I merge everything here without repeating all the properties?
}

谢谢

4

0 回答 0