How to create a multi step wizard to dynamically add/edit objects in Navigation properties in MVC

394 Views Asked by At

I am working on my first MVC 4 application. We are using Model first approach for this application. I am working on the add employee module which has multistep wizard. Employee class looks like below, it has couple of navigation properties for other tables,

Employee
{
    Employee Properties;
    .
    .
    ICollection <ASSET>;
    ICollection <TEAMS>;
}

I am using a viewmodel having an object of employee entity and other Select list objects for the dropdown lists required during add process.

public class EmployeeViewModel
{
    Employee NewEmp;
    .
    .
    List<Country> Dropdown1;
    List<City> DropDown2;
    .
    .
}

I have created a strongly typed view to pass this viewmodel in add screen. Add wizard is divided into 8 steps and each step is rendered through partial view. Everything works fine for the properties of Employee entity. But I have steps where,

  1. User can select from assets from dropdown list and tag them to employee currently being added.
  2. User can tag employee to the team, select employee role,etc.

I want to re-use these partial views in edit mode also, so I believe the navigation properties will have list of valid objects in case of edit mode. The idea is to add/edit all the information in viewmodel and save it to database on finish button. I want to understand how can I create and add the objects for navigation properties in current viewmodel. Also how can I re-use these 2 steps in edit mode ? Can I create new team objects at client side and add it into a employee object collection list? Is there any other way (like using Ajax) to implement this functionality? Please help me because I am really stuck with this from long time.

0

There are 0 best solutions below