Confused with MVC scaffolding - asp.net-mvc-3

I'm learning MVC3. There is something I'm trying from many hours and now I think I'm totally lost.
I created a database first, then generated Models from it. Now I wanna know if it is possible to use scaffolding to generate a model with CRUD views? I tried several things. Firstly the error- Unable to get metadata.
Googling it first misled me that there is something wrong with EF4.x. Reinstalled it and wasted time. Then I tried Automatic Code Generation feature but its giving ambiguity errors between previously generated classes.
Is it even possible to do what I'm trying? How? Or do I have to code for the views?

Go to your controller method, right click and add your view, You will need to check strongly typed-view then select the model and the scaffold template.
If you still get an error, make sure you decorate the primary key with the attribute [key], also make sure all properties have the same name as your DB field or you will get an error.

Related

How do I use Nova components in a custom tool or card?

I'm currently working on a Laravel Nova application in which I need to add a lot of custom tools and cards. I'd like to keep consistency across the whole application, so it makes sense to simply use the existing Laravel Nova components for certain things like form inputs.
I am trying to use a couple of different components found in the nova/resources/js/fields.js file, but it is not working.
In my code, I am simply referencing the <form-date-time></form-date-time> component, but I am receiving errors:
Cannot read property 'attribute' of undefined
Cannot read property 'value' of undefined
I am not a Vue expert, so I'd imagine there is something pretty clear and obvious I am missing. In another SO post, someone referenced doing the same thing I am trying to do with the Nova checkbox component. In that case, there was a prop that needed to be passed to the component in order for it to function correctly, but I don't see a prop that I need to pass to the component at nova/resources/js/components/Form/DateTimeField.vue.
Any help in using Nova components in my custom tools and cards would be appreciated. Thank you.
Figured it out. Apparently all the Nova built-in components are available globally. Didn't realize this. All I needed to do to get it to compile was remove the import statement.

Laravel localisation - database content

I'm looking at frameworks and CMSs for a project we are starting, a website that needs to support localised content.
Laravel looks good and certainly allows you to localise UI content, but it doesn't seem to natively support the localisation of content stored in a database. This seems surprising, I'm wondering if I'm overlooking something? (CakePHP, for example, has a TranslateBehavior for this purpose).
Edit To be clear, I'm asking if there's anything baked into Laravel to handle this, I'm aware I could code equivalent functionality but think that that would be a fair amount of extra work.
Modifying your data as it enters or leaves the database is fairly easy.
If you store the translation key in the database, you can translate when you pull the data out. Use getter and setter methods in the model. You may also want to look at Model Events.

what is the correct approach in order to host / integrate / show my existing MVC3 project inside orchard?

I've an existing MVC3 project that implements a certain functionality, this project has it's own views, and a separate Database.
now I'm required to use the same functionality inside one of my orchard project,so I thought that I can host this solution in somewhere and view it inside an iframe or something.
Am I thinking right?,
is this the correct step to take in order to achieve this requirement inside Orchard?
to make it more clear, all I need to do is to view this solution and interact with it's controls and views from a hosting page inside orchard, and the subsequent requests should be handled by my solution in order to hit it's own data store and get back with the requested data in order to be displayed to the user.
any help would be appreciated.
Update:
thanks for Bertrand Le Roy for his answer, I can now view my solution inside my
orchard website.
I came in to one more HUGE problem, which is that my application can no longer connect to my external database.
I've a DB that is hosted in some where else, and I'm using EntityFramework to deal with it.
the problem is that if I put the connection string inside my module web.config, or main orchard web.config, I run into several types of errors like:
"System.Reflection.TargetException: Object does not match target type."
or
"System.Data.MetadataException: Unable to load the specified metadata resource."
My question is: How could I pass my connectionstring correctly to my solution, assuming that I'm using Entity framework as my ORM.
Many thanks.
You will need to put it into a module.
You will have to move route definitions to a Routes.cs file (look at any existing such file for examples).
You will also need, in order to access your data store, to opt out of the ambient Orchard transaction around the data access code (using (var scope = new TransactionScope(TransactionScopeOption.Suppress))).
If you are using dependency injection, you may have some work to move that to the Autofac-based way of doing things in Orchard.
If you want your work to appear seamlessly in the Orchard admin, you may want to decorate your admin controllers with the Admin attribute. If you want your front-end to use the current theme, you'll have to add Themed attributes and maybe refactor your views so that they only emit HTML for the content zone instead of for the whole page.
Add a manifest (module.txt) to your module folder and you should be good to go.

yii - form/modal based on mongodb

I am using mongo db in my yii project.
I am newbie in yii and mvc. I need to show some fields from database to user. And also allow them to edit those fields when they click edit. From what I know so far, I need a modal to create form. Modal should extend CActiveRecord (because I am allowing edit).
But I have no clue how this is going to work with mongodb ? Its very differnt from mysql (structure and fields are not definite in mongodb). Some users have field (column) abc while some do user do not have it.
I am looked into the mongodbsuite for yii. But its very hard for me to understand that at this level.
I am willing to write my own custom code, if someone can give me a direction. (or I'll have to write my own code destroying the feel of yii/mvc. Fetching everything and inserting into textboxes and then allow users to edit those)
I think this extension will help you. Pls check - YIIMongoDBSuite
What i suggest instead of writing your own code and doing testing to make it work, it is always better to shift to mysql,oracle or anything that Yii supports. it would save life
Yii Supports
SQLite
mysql
PostgreSQL
SQL Server
Oracle
It might be worth asking this question on the yiiframework forum
http://www.yiiframework.com/forum/
where there seem to be people actively using yii and mongodb.

How to delete CodeIgniter db class?

I've started a CI project and I'm going to use it with Doctrine, there is benchmarking system for the latter and I'd like to remove the ability to use native CodeIgniter DB class, since it won't be benchmarked. I though about simply removing the corresponding files, but I'm afraid it could cause CI errors in other places. How can I remove the ability to use native CI DB class?
I personally would not do it. I just want to force the future developers with random level of qualification not to load it as well
I also use Doctrine in connection with CodeIgniter and there is no need to do anything with the CI DB class. Just ignore it and use Doctrine as you would do normally. If you don't use the DB classes or don't load it, they won't get benchmarked.
If you haven't already found it, look at the wiki, ot gives a good idea what to do with Doctrine
edit to your 1st comment: If you really want to disable the DB class, I see one way: either delete the core file(s)/folder(s) or rename it so that a loading just fails. Alternatively, change their code so they cannot be loaded. If you do so, it should be really well documented somewhere so that the error will be obvious to someone after you.
Don't load it in your controller.
Theoretically, you could create a hook and disable CI's DB functionality. In the hook, you would extend the CI_DB class and the display an error message if the class gets loaded. I'm sorry I can't give specifics, but you'd probably have to inspect the system's database classes to see what would need to be altered.
At least that way, you wouldn't need to make changes to the CI core.

Resources