Form for many to many relationship in MVC - asp.net-mvc

On an MVC view I need to display a form to insert user data and its courses.
For each course the user must choose: name, number of days and location.
And the user can choose many courses ... I don't know how many.
So basically this a form with a many to many relationship.
What options do I have for such a form that is easy to use?

You should have some entry points like a user or a course to view its details. For example, if you go to details of a user, you can see all the registered courses in a table/grid, you can have an autocomplete dropdown box for adding a new course. You can apply the same thing for a course details page as well.

Related

Umbraco add items dynamically

I have a problem where I cannot figure out how to solve.
Lets say i have a company with products. I want to be able to add new products, delete products and edit current products.
I also want to list these projects on a product page.
I know how to add pages and so on. But does this require that i need to create a single page for each product? And then get all childpages information?
I am greatful for any suggestion!
It depends on what you want to do with the products. If you want to have a product detail page, then it makes sense to have a page for each product.
On the other hand, if you want to just list the products and not have a page for each one, you could use something like Archetype, or Nested Content.
It's also worth bearing in mind that if this is going to be an e-commerce site, there are a number of excellent options available that you could use for product management etc. You should investigate uCommerce, Tea Commerce and Merchello for example, to see if they offer the functionality that you require without needed to write too much yourself.
Work through the beginners' tutorial
https://our.umbraco.org/documentation/tutorials/creating-basic-site/
The articles parent and child model can be used for what you need (instead of "Articles Main" you'd have "Product Listing" and "Article Item" would be "Product"). If you don't need a specific page for each product just don't assign a template to the product nodes.

How do I model my Rails application where users search for events and save the ones that interest them?

I am using three models:
- users
- events
- user_events (the join table)
I feel like I do not need to save every search result because it would be unnecessary. The search will query two APIs and display maybe the top 10 results and display them to the user. The user then might be interested in one or two of these events and add them to a list of things that interest them, a bookmark, if you may. Bookmarks that are happening on the same day should then be grouped together for the users organizational purposes.
Should I make another search model along with a search controller? I'm fairly new to Rails and need some advice on this topic.
I would advise you make a bookmark or search class to store a search when a user wants to save it. Then you can construct a has_many relationship between a user and a bookmark. So a user will have many bookmarks. See this for more documentation: http://guides.rubyonrails.org/association_basics.html#the-has-many-association

Model record/instance specific view

I have 8 plans for the user to choose from. These plans all represents forms which would results in products added into the cart.
A few plans will ask different questions. For example plan A,B,C would ask the user if he/she want to purchase additional addon. Plan D,E would ask the user the total credit to store in their account.
This seems to suggest that we have separate views for each of the plan. But this means we then need to add show and edit actions for each of the plan. A bit tedious. So I want to ask if there is a pattern for having record specific view in Rails.
Not really sure if this can be answered in any specific conclusive way, but I would use partials in such a case.
let's assume your plan has a type field somewhere you could do the following
<%= render partial: "plan_#{#plan.type}" %>
Whereas each of these _plan_X.html.erb partials contains the plan specific information you want to display.
This pattern can be adopted for all of your views (maybe your edit action has different data depending on your plan type etc.

User profile with devise, checklist app

I am new to rails and I am currently in the process of developing a check list app. I would greatly appreciate some guidance as I am currently suck in my development process and would just like some help getting me on my way.
Goal:
Admins will have the privileges to add collections, and add products to those specific collections - (all will be pre-populated and defined before the site goes live).
Users should arrive at the homepage, be presented with a splash page of what the page is and be able to sign in/ up. Once signed in the user should be directed to their profile page.
a.) first time there, they should be presented with a list of collections they want to 'follow" / "watch" (that show up on their profile page to track the products they are missing from the entire collection)
b.) second time there, they should be presented with the collections they are watching, and the all products in that collection.
Once on their profile page, they should be able to "check" and "uncheck" products in the collection. I want to show all the products in the collection regardless if they have them or not, and they can check the ones they have, and I will do some fancy front side stuff to make it visually appealing. (fade from black / color - on true/false value - animate all selected ones to front of container..ect)
What I have:
I have a Collection(has_many) -> Products(belongs_to) association models set up. I have both of the controllers CRUIDified, and the product page is CRUIDified through association with collection. (nested routes / #collection.products.build etc.)
I have a generated Devise User model with email confirmation. I gave that model a User(has_many) -> Collections(belongs_to) association.
My next steps?
I am trying to assign a user to a profile page that I can display the results of the their collections/products. I am stuck as to how to achieve this. Do I need to create a user controller and put a before_filter :authenticate_user! and limit the actions I don't want accessible by normal users? Or do I need to generate a new Model Profile, and put an association there?
If you would like to see my current code it can be found here:
https://github.com/gogogarrett/Blind-Boxd
Thanks in advance,
Garrett
If you want to have a page for signed in users to see their collections and products, you don't necessarily need that to be in a User Controller.
I have put my user overview pages in a pages_controller. You then have a before filter of :authenticate_user!, and you just pass whatever you need into the view (#collections = current_user.collections).
It doesn't sound like you need a new model.

ASP MVC Creating Form Rows Dynamically

I haven't even attempted this yet and am creating this question for advice really.
I have a strongly typed page which receives a form model composed of several components. It is to create a mitigating circumstance (MC) for a student at a university for my final year project. A MC can be composed of the initial problem, assessment extensions, and I use a multi select box to allow the user to select staff retrieved from the database which are able to view the MC once created.
The thing is I feel that a student could be granted many assignment extensions for one problem. I am wander if it is possible to include a button/image on the form which when clicked will create a new assessment extension object, and duplicate the form components to set the values for the object? This would all need to occur without any page refreshes.
Any advice, or links to good tutorials would be appreciated. I have so far been unable to find any suitable examples.
Thanks,
Jon
There are a number of ways to do this, but the fastest is to create a javascript handler which creates the form controls without any sort of server request, all you need to do is keep track of how many items are in your list so you can name the form controls correctly.
Start by making a button that when you click on it creates form controls. Once you get that, work on the naming.

Resources