简体   繁体   中英

ASP.NET MVC - Multiple inserting into database

I'm bulding an ASP.NET MVC web app using the Razor engine. Before explaining my issue, I'd like to explain you the context. I've an Users table and a Group_Tests table. An user can subscribe to a group of tests by mentioning the hours of notification (AM and/or PM) and the frequency (10 times per day). Here's the model (build with Entity Framework from my database) :

在此处输入图片说明

The thing is, I want my users to subscribe to test groups by choosing AM or PM (would be checkboxes) and validate it. It could be more than one group. However, I don't know how to do it. I can easily imagine that I've to create a ViewModel and into my View, doing a foreach loop on my Group_Tests table to add a row of subscription for each existing group.

Any idea guys?

I can easily imagine that I've to create a ViewModel and into my View, doing a foreach loop on my Group_Tests table to add a row of subscription for each existing group.

You've pretty much got it. But to be honest, we can't help you if you don't post your attempts.

Unless there is a specification requiring users to be able to subscribe to ALL Group_Tests at once, I'd opt for having them choose the desired group_test from something like a dropdownlist rather than rendering an object for every type of Group_Test conceivable. That way, they can subscribe to each Group_Test individually.

If it's really required to subscribe for everything at once, you're on the right track.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM