title: Best Approach to edit my model class in seperate stages, inside my asp.net mvc web application
body: <p>I am working on an asp.net mvc-4 order management system. Where I have the following Order model class:-</p>
  
  <pre><code>    public partial class SOrder
          {
      //Stage 1
              public string OrderNumber { get; set; }
              public int CustomerID { get; set; }
              public int OrderStatusID { get; set; }
              public int OrderTypeID { get; set; }
              public int CommissionTypeID { get; set; }
              public string QuoteNumber { get; set; }
              public string ServiceName { get; set; }
              public string ServiceDescription { get; set; }
      //stage 2
              public int Quantity { get; set; }
              public string AssetID { get; set; }
      //stage3
              public Nullable&lt;System.DateTime&gt; LiveDate { get; set; }
              public int ContractLength { get; set; }
     //system generated     
          public System.DateTime Created { get; set; }
          public System.DateTime Modified { get; set; }
          public int CreatedBy { get; set; }
          public int ModifiedBy { get; set; }
          public int StageNumber { get; set; }
     //code goes here 
          public virtual OrderStatu OrderStatu { get; set; }
          public virtual OrderType OrderType { get; set; }
  
          }
  </code></pre>
  
  <p>Now I want to allow editing the model in 5 separate stages. Where each stage will be handled by separate group of users.
  Current I am following this approach, where inside my view I am checking the stage number and hide the related fields accordingly:-</p>
  
  <pre><code>@model S.Models.SOrder
    @{
        ViewBag.Title = "Order";
  }
  
  
  @using (Html.BeginForm())
  {
      @Html.ValidationSummary(true)
      @Html.HiddenFor(a=&gt;a.OrderID)
      @Html.HiddenFor(a=&gt;a.StageNumber)
      &lt;div &gt;
      &lt;span class="f"&gt;@Html.DisplayNameFor(model =&gt; model.CustomerID)&lt;/span&gt; 
  
      @Html.DropDownListFor(model =&gt; model.CustomerID, (SelectList)ViewBag.Customers, "Choose...") 
      @Html.ValidationMessageFor(model =&gt; model.CustomerID)
     &lt;br /&gt;
      &lt;span class="f"&gt;@Html.DisplayNameFor(model =&gt; model.ClientManagerID)&lt;/span&gt; 
  
  
   //code goes here..   
  
       if (Model!=null &amp;&amp; Model.StageNumber &gt;= 2)
      {
              &lt;div&gt;
      &lt;span class="f"&gt; @Html.DisplayNameFor(model =&gt; model.AssetID) &lt;/span&gt; 
  @Html.EditorFor(model =&gt; model.AssetID) 
      @Html.ValidationMessageFor(model =&gt; model.AssetID)
  &lt;/div&gt;
      .....
      }
  </code></pre>
  
  <p>And here is how my Post edit action method looks like:-</p>
  
  <pre><code>         [HttpPost]
  
           [ValidateAntiForgeryToken]
           public ActionResult Edit(SOrder sorder)
           {
  
               try
               {
                   if (ModelState.IsValid)
                   {
                       var dborder = repository.getOrder(sorder.OrderID);
                       repository.DetachedOrder(dborder);
                       sorder.OrderNumber = dborder.OrderNumber;
  
                       sorder.Created = dborder.Created;
  
  
                       sorder.StageNumber = tmsorder.StageNumber+1;
                       //code goes here.
  </code></pre>
  
  <p>But I am facing these issues:-</p>
  
  <ol>
  <li><p>Currently unauthorized user or hackers can pass the fields which is not showing inside the view, by using tools such as fiddler. So is there a way to handle this logic inside the Post Edit action method? So I can force users to only edit the related field at each stage?</p></li>
  <li><p>I am thinking of another approach to handle my logic. By using 5 view model classes, one model class for each stage, instead of one model class at all the stages as I am currently doing. But when I start doing so I realized that I need to have 5 different Post edit action methods. Because each edit action method should accept the related model class. So not sure if I can benefit from view models to implement my stages?</p></li>
  <li><p>Is there any other approach I can follow, to allow modifying my model class in stages?
  Thanks</p></li>
  </ol>