-2

I am working on online resume building project using ASP.NET MVC and let me tell you that I am not that much familiar with MVC.I have two view models, one for the information about experience and another for other resume details.Basically one person can have more than one experiece that is, resumeVM have one to many relationship with experienceVM and my view models look like this;

public class ResumeVM
{

//some variables

public List<ExperienceVM> experience { get; set;}
}

public class ExperienceVM
{
//some experience details
}

Now the problem is how do i create view in order to let user enter as many experience as he likes.I guess I can create UI using javascript but I don't know how can I store those values into list and save those data in the respective table.Can somebody throw light quickly on this about how to proceed??

  • maybe read some articles about mvvm or mvc first. stackoverflow is not the place for this sort of questions. – Bizhan Jan 05 '17 at 12:01
  • Hi, sorry but no. You asking to write you an article to explain how to do something. This is not what SO is for. And all what we can do in your situation is to suggest to take any mvc master-detail like turorial and maybe you get an idea how it works. Good luck. – Renatas M. Jan 05 '17 at 12:03
  • first of all I have taken some classes on MVC and indeed have gone through some articles.I am sorry I am not asking to explain it like in article, my question was how could I implement one to many relation in view. I tried but it was not working so I though of taking help from you guys. – user7378251 Jan 05 '17 at 12:15

2 Answers2

1

If you have problem with sending 2 Models into your view they are several ways, one is as you said ViewModel which be like below:

public class ResumeVM
{
    public ResumeVM()
    {
        Resume = new List<Resume>();
        Experience = new List<Experience>();
    }
    public List<Resume> Resume { get; set; }
    public List<Experience> Experience { get; set; }

}

Create Lists of your model in your ViewModel And Populate them in a factory or In your Controller and send them with view:

   public ActionResult Index()
    {
        ResumeVM _vm = new ResumeVM(); 
        Repository _repository = new Repository();

        //these repository methods will populate your lists 
        _vm.Resume = _repository.PopulateResume();
        _vm.Experience = _repository.PopulateExperice();

        return View("Index",_vm);
    }
Masoud Andalibi
  • 3,168
  • 5
  • 18
  • 44
0

If you need more models in view then you creating ViewModel - something beteen Models and Views who can stack many models to your view

For better understand what it is read this and this

Community
  • 1
  • 1
J. Doe
  • 2,651
  • 1
  • 13
  • 31