Create a New big Object Wizard: ASp.net MVC - asp.net-mvc

Here's my question:
I need to write a wizard, for customers to "create a new" very big objetc, with some other asociated with it: for example, Some images stored in another table (with relationships), some Lat's and Lang's for google earth, etc.
Each of them are stored in diferent tables in the Database, and that's why, i have to first insert to get the first object's Database generated ID to make the relationships with the another Objects. That's the reason I think puttin' Everything on just one View and hide selective DIVs with Jquery is not one of my option.
Session isn't an option because of the bigger object.
And because of the type of website, the wizard MUST be as follows:
Basic details of objetct 1
Images of object 1 (I will need here the ID of the first object)
Geolocations (with google maps, as before)
More details of object 1.
Preview
Publish
The point is, in step 4, user fill some fields that are required by the DB, and I cannot make them nullable as is it part of the customers reqs.
If somebody can a least give Ideas, will be nice...
Thanks in advance

You state that storing your object in Session is not desirable because of the size of the object. An alternative is to serialize that object and store it in the database. As the user progresses through the wizard, that object gets retrieved, updated and stored back in as a blob. Once they publish it, you can insert the appropriate records and remove the serialized object from whatever table you're storing them in.

Related

getting mvc index and details for to display an actual value vs an ID value?

yeah the question is: can mcv display on the details and index form the text data values vs just ID value that gets stored in the database .
It seems that mvc is very limited in what it can display to the screen. All of the demos and tutorials seem to stop short of showing this is a possibility most just show the user typing in the the full text value. So for example the user has a user interface form that has a list of values drop down element. THey click the value and the ID gets stored to the database.
Later on recall the user wants to pull the data back up for review... in mvc it seems you are stuck with displaying the ID field in the textbox.
but in most other systems you can make a datatable and return the text value of the field back to the form... Is this possible with MVC or are you limited to saving the full text value to the the database?
enter image description here
enter image description here
yeah the answer is: Make a view in SQL Server and then Link that View to the application via the EDMX. Details below.
Finally! I was able to figure out and I will post the solution so that it may help some one get around the mvc / normalized database limitation that seems to exist when you try to follow some of the tutorials.
The key is to build a SQL view outside of MVC. This can then be linked to the application and it will appear to be a table.
So if you use the database first method and you are using SQL server you will need to simply make a view in SQL server. This take mvcs out of the picture all and is much easier.
Step 1: Make a SQL view... that has everything you need joined in one big super view for what you need to display.
So in my case I made a sql server view that has the storage table linked to the support tables. Think of the query builder in MS Access where you link your tables to make a query.
You draw out your tables and links.
Add that to your Database First EDMX and in your controller use that new super view... and in your index and details forms you change the #model to your new super sql view and change the field name in the textboxfor... Boom problem solved... pretty swell how it all works... in this way you don't have to build some complicated view model. You just take the class that the wizard builds and then make a partial class to rename fields to give them user friendly names.
And you are no longer limited by mvc limitations
hope this helps!

Breeze delete Projection

In my application I have an "Event". And to this Event, I can attach documents.
Now when I show a dialog of this Event, I want to list all the documents, that are related and I do this with a "select"-Projection (because I don't want the property in the document, that has the binary representation in it, which would be huge).
Now from this list, I should be able to delete a document. As I did a projection, I don't have a breeze entity for the document so I cannot call setDeleted() on the entityAspect.
How would this be done? Do I have to query the whole document just to delete it?
I do all of this in a sandboxed DataContext so just sending a command to the server to delete the document and requery is not an option - as the dialog can be cancelled.
If I do this with standard queries and navigation properties everything works fine but potentially slow if there are big images.
Check out this answer. Essentially, you can create an entity with the id of the entity you want deleted and set the entityaspect to 'deleted' and that should take care of it.

Core Data: Which record loads by default in core data if you do not specify which one?

I have a static table for settings where I want to pull some stuff from an entity in Core Data. The use case does not lend itself to a table of records as you usually see. Rather each row of the static table is really a field related to the user--as in a user profile. I have a feeling that in testing I may have created more than one record in the entity. I know there are programs that let you see the SQL lite database underneath, but my question assumes you do not have this tool and are relying just on Xcode.
My question is when you have more than one record in a Core Data entity/table, and you try to load data from the managed object context into a VC, one field into one element, what record is shown by default?
Related to this, if you don't know how many managed object or rows are in the database, is there anyway to specify which record you want since there are no auto ids as you would use in a traditional database?
The record that gets loaded from the fetch first. Depending on your sort that might be consistent or it might be random.

ASP MVC 3: Is there a way to have an object in session expire after the user leaves the view?

I have the following problem. In a view I have in ASP MVC where I need to store the original object that was received by the view and compare it to its modified version (which is the result after modifying the original object in the view).
The problem I have is that since the original object is not bound to the view (because there is no reason and I would have to create many hidden fields for this) then it is lost unless I store it in the Session. However, this can cause another problem because if the user leaves the page through the navigation menu instead of saving his changes this object will be left in session until it expires, which I think is not good.
It seems to me that you're trying to reason in a "windows forms" or "web forms" way.
So you need to detect the changes made to your object. The pattern to achieve this is rather simple:
Get your object from your datastore (whichever it is) and send it to the view
Display the fields to edit your object. Have a single hidden field with the id of the object.
Post the data to your action method. Retrieve the original object from the datastore using the id, then update the original object with the new values from your post.
Persist your changes to the datastore.
As you see, no need to store anything in session. Other than being useless, it would be bad practice.
Why not store the original object in a database and retrieve it from there when the user posts the updated version?
Why not use a ViewBag? It is alive for only as long as you are on a particular view.

Master-Detail with jqGrid+Asp.Net MVC and transaction

I'm coming from the delphi world and I want to make a master/detail interface, like Order and Products.
I already made actions to display the data using fields and a jqGrid. What I want know is how make possible to add lines, edit or remove them, but, just make the changes in db when the user confirm the changes in the master.
On delphi I would use a TClientDataSet with all the in memory changes and just after the confirmation would execute them inside a transaction like:
BEGIN
Master.Post
FOREACH Line IN Lines Line.Post
COMMIT
So in resume, I don't know how keep in memory the array of lines in the grid and how send them back to server to commit.
Any help will be appreciated. Thanks in Advance.
You'll need to keep track of the changes client side, perhaps using some hidden fields and/or form fields in your grid. When a line is deleted (that previously existed in the db), you'll need to add it's id to a field containing lines to delete. Lines that are added need to have associated form fields containing their data. When the master is committed you roll the whole set of fields up into a POST and send that back to the server.
Using LINQ to SQL, you'd create a data context, get the master object, then delete the related objects (from the hidden field of ids) that are so marked and create/add new related objects that didn't exist before taking the values from the appropriate form fields. Then you'd do a SubmitChanges and all of the statements would be executed within a single transaction.

Resources