recently i thought to apply roles to users in a different way,without using role manager etc.like create one column named 'ROLES'...and redirect user by checking this column at login time.I know so many of you are thinking what is i am gonna do.I am also thinking the same.I know one drawback of this technique,that is one user cant have multiple roles.Is there any other drawbacks of this technique and why should this technique be avoided and one should use role manager instead of this?
Well Rohan, There is nothing wrong with your way. I have used this type of techniques for 2 years because I was too lazy to go thru the role managers and overriding it where needed.
However i feel now that I have always reinvented the wheel. Its your persective how you see that.
and your last question "why should this technique be avoided and one should use role manager instead of this?" the answer is because it is readymade and timetested. Any new code that you write has a theoritical limit that it can have bug, so suppose you have rolled out your own authentication engine- you will have to test it.. Isnt it extra efford that you have to put?
Use that Link, I think it will help you..
Can anyone tell how to update table rows dynamically in entity framework? I am new in entity framework. Thanks in advance.
This is a pretty general question, but what you need to do is basically this:
Access your data context.
Get a given object (/record) from your context (/database).
Change the object.
Call SaveChanges() on the data context.
If you are learning EF a site that helped me a lot when I was learning it is http://msdn.microsoft.com/en-us/library/gg696194(VS.103).aspx. It contains lots of information in problem/solution format. You can also look at this book:
http://www.amazon.com/Programming-Entity-Framework-Building-Centric/dp/0596807260/ref=sr_1_1?ie=UTF8&qid=1355991856&sr=8-1&keywords=entity+framework
or this book:
http://www.amazon.com/Programming-Entity-Framework-Code-First/dp/1449312942/ref=sr_1_4?ie=UTF8&qid=1355991858&sr=8-4&keywords=entity+framework
which are both quite useful depending on whether you wish to use the designer or Code First.
http://www.silverstripe.org/archive/show/1638
The above post seems like it's what I should do but I just need some help sorting this out in my head.
Firstly, I need to create a relationship between a page (Owner, for example) and a dataobject (Car). An owner can create many cars which are linked to that one owner. However, I have another page (Garage) which can create cars that are linked to every owner. If an owner does not want one of these cars they reject it. I was thinking the manymanydataobjectmanager would be good for that bit.
Each owner should only be able to see the cars that relate directly to them within the CMS, not other peoples cars, so I was using dataobjectmanager and assigning permissions to the page using groups.
The thing that is really making this awkward is that when it's all set up I need to output JSON which will consist of the cars the owners created and the cars they accepted from the garage, not the ones they rejected. I'm thinking I need another table like the linked table but with a status column perhaps?
To clarify, my question is how do I create this mess in a constructive SilverStripe way? Is the approach I was taking correct or is there a better way?
Many thanks in advance and please tell me if I've been unclear.
are you using silverstripe 3?
could you clarify what of the actions happen in the backend and what actions are possible for the user in the frontend?
maybe for your relations it could be better to use ModelAdmin:
http://doc.silverstripe.org/framework/en/reference/modeladmin
It gives you the opportunity to manage relations without the Sitetree/Pages Overhead. For example creating a Sitetree Element just to have an Owner is not the best way - except if you really need an Owner represented as a real Page. Owner could be also just a Dataobject instead.
Especially if you want to output just JSON in the end you are maybe completely independent of Sitetree/Pages... then you could write a custom controller with a routing rule and which gives you back just the data that you need:
http://doc.silverstripe.org/framework/en/topics/controller
regards,
Florian
I'm looking for a bit of advice with regards to the structure of an application I'm tasked with.
I need to have a series of webforms to store some data, most of the data is the same but each form would have some differeing data depending on the form used.
Would a base class then a series of classes inheriting from this for the specific data be best to use?
As in:
order - compAOrder
- compBOrder
- compCOrder
How about strucuting the database for this sort of application structure?
The answer to this kind of question is allways "It depends" but here is a possible solution:
Program the system with a single web page for form data input.
Use a query string value to identify which form it is.
Hide and enable fields depending upon which form it is.
Have a single data table that has all the possible fields.
Hope this helps
Shiraz
I eventually went with a catch-all table with all the fields and different forms.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
At my job, I have to implement web forms for loan applications with sometimes up to a hundred different input fields, and then save the application into the database for later retrieval.
The person whom I replaced created a sql table with 100s of columns where each row represents a loan application and there is a column for every field.
The problem with this is that I find myself having to type out the 100 fields a bunch of times, getting data from form, saving to database, retrieving from database, writing to output webform.
And then whenever there is a change to the application, I have to make the change in quite a few places.
So it can not only be cumbersome but error prone.
Is there a good design pattern that handles this?
See if you can come up with a better table design. 100 Cols is just too much IMO. If not you could use dynamic data. Also look for a better UI pattern or break it into more than 1 pages, looking at 100 fields to fill in could be over whelming for the users.
Code generation is the best bet. MyGeneration and CodeSmith are two very good tools.
I've had very similar projects and I used both generation tools and prefer CodeSmith.
100's of fields in a form is too many. Try to aim for max 20 per page.
If you can, try to isolate each part of this form into a separate page, and even better, into a wizard of some kind.
e.g. (example steps)
Step 1: Client Profile (name, age, SSN, etc.)
Step 2: Loan Data (Fixed, Variable, Amount, Terms, Special Deals...)
Step 3: Credit Check?, Pre-Approval?
Step 4: Variations/Calculations...
If you organize the data in structured groups, you should be able to make each portion work independently (e.g. you can input basic loan data, and get some preliminary numbers without needing to enter client data (yet).
More importantly, if the user enters a value in one of the 100 fields that causes the backend to not store (e.g. value out of range) what happens? does the user lose all the data they entered? - for usability make sure that nothing is lost when the user attempts to save/move to the next step.
Perhaps ASP.NET Dynamic Data would work for you. It is described as "a framework that enables you to quickly build a functional data-driven application"
I've worked with these loan applications before and I'll tell you straight out that your data model is broken. Are you gonna make a new row in the BigTable when a borrower comes in for a refi? What if the deal falls through but they want to try again for a different house? If you just edit the data in the row for that application then you're losing valuable metrics on your % of closed deals.
First, fix your data model. Then, embrace LINQ if at all possible.
With respect to the UI, I'd either do it as a wizard (which is pretty close to how these apps are filled out) or build it as one big form that the user scrolls through and adds stuff to (use AJAX in each section so that the user can save as they go along).
You also need to consider off the shelf solutions for this stuff. Don't reinvent the wheel here; these loan apps don't change often enough to throw a full time developer at them.
Edit: Sorry I was assuming that this was for residential mortgages. I don't know if that's true, but I still think your data model is broken. If you have the ability to change it you should.
Design pattern? But of course: The Adaptive Object-Model.
One thing that you can do is programmatically take the column names and put them on a file in the format you need. That will be to solve your immediate pain. Below is a piece of c# code that will get the column name from a oledbreader object.
internal List<string> GetFieldList(string sTableName)
{
tableName = sTableName;
BuildQuery("*");
command = SetupConnection();
List<string> FieldList = new List<string>();
OleDbDataReader reader = command.ExecuteReader();
for (int i = 0; i < reader.FieldCount; i++)
FieldList.Add(reader.GetName(i).ToString());
return FieldList;
}
To solve the situation in the long run, you probably want to do store procedures or functions with the fields as parameteres. you still have to put the values in each of the parameters, but is going to easy the management of each
he problem with this is that I find myself having to type out the 100 fields a bunch of times, getting data from form, saving to database, retrieving from database, writing to output webform.
hope it helps!!!
Ouch.
Is LINQ available to you? What version of .NET are we talking about here?
BTW, if it isn't obvious already, from a GUI perspective I suggest you hide most of these fields from the end user and reveal them in sections as the user progresses, which has the advantage that you can avoid showing what doesn't need to be and validate as you go.
And with some sort of progress indicator so they know there's an end in site (ha ha).
I've had issues like this before, and know there may be valid reasons for having so many columns. It's rare, but it can happen.
What you might want to do, is create a partial class in it's own file which contains all the data field code. This might be fields, properties, and possibly method parameters, and/or just your CRUD functionality. And generate that partial class, this will help ease your future maintanence.
Good Luck.