Store Umbraco Member Properties in Separate Table - asp.net-membership

I want to create a membership based site in Umbraco 7, following the umbraco.tv videos and reading through the docs have got me quite far.
My members will have custom properties, firstname, lastname, favourite colours, hats owned etc. I have been adding each of these as custom properties and then assigning them to the tab I want. This works fine and I can then access them from code using:
Members.GetCurrentMember().GetProperty("lastname").Value.ToString();
When I looked in my database I noticed that each of these custom properties is a row in the cmsPropertyData table, linked to the cmsMember table by the nodeId column. Is there a way I can set all of this information to store in it's own table?
Ideally, I want each Member to have a one to many relationship with favourite colours, as well as one to many relationships with other tables; each member might have 100 hats for example. What is the best way for me to set this up? Shall I create custom tables in my Umbraco database for HatsOwned and FavouriteColours, then assign each Member a unique ID so I can set my foreign keys up correctly? That way I would only need to store the Members Unique Id in the cmsPropertyTable. Is there a better way to let Umbraco deal with it? Would I have difficulty retrieving Members using either the Umbraco orm, or EF?
Any help or pointers greatly appreciated!

I would store all data in the PROFILE of the member, in the umbraco membership. E.g. timezone, hair color, ... This makes sense for other developers to find back the data.
For all other data, you have a few options:
Relationships
If you want to link nodes to members, or nodes to nodes, or... Relations link 2 umbraco entities and can be one way or two way. If you have a color node, you can link all members to this node. Just create a "favoriteColor" relationship on the developer section, linking up nodes to members. Do some programming and you are done. Don't forget that a relation is a database record linking 2 umbraco entities. So think of some caching if you use this in your front end to take off some database load. Read more on the Relationship Api in the umbraco documentation.
Content
It's pretty easy to create new nodes using code to store e.g. comments on an article. Because you are republishing the xml cache every time you create (and publish) a node, don't use content nodes for stroring your data if you have a lot of updates.
External data
It is perfectly legit to store data outside of umbraco. Just create your own tables (or content to any service you created). You could use every ORM you want to, but I would recommend PetaPoco. The reason is obvious. Umbraco uses it also. And it will make you a better Umbraco developer. There is a detailed post on stackoverflow on how to work with external data in umbraco.

Related

PowerApps M:M relationships with additional attributes

I'm new to PowerApps. I'm creating a model-driven app. I've created some custom tables in the DataVerse - Information System, and Business Process. These tables have a M:M relationship. An Information System supports one or more Business Processes and a Business Process can use one or more Information Systems. I need to capture additional attributes that describe the nature of the relationship - what role does the Information System play with respect to the Business Process, and a score indicating how effective the Information System for that Business Process.
I've learned how to create M:M relationships using the built-in functionality in PowerApps but this does not permit me to define additional attributes for the relationship.
I've created my own M:M "middle" table and created M:1 joins from that table to each of the related tables. My "middle" table contains a lookup to each of the other tables and the additional attributes I need.
I need to know how to modify the default form for each of the related tables to include the "middle" table to enable a user to select a row from the "other" table and also to supply values for the additional attributes. I have searched for several days now and have not found any literature explaining how to do this.
I'm hoping there's someone who knows how to do this or can direct me to some literature about how to do it.
Thanks in advance for any assistance you can provide.
What you did is right, initially you created a native N:N relationship and for your need it should be manual N:N relationship which you created later.
You can add the subgrid of manual N:N intersect entity (two lookups and extra attributes) in both the main entities - this way you can create related records from either side. It can be a related navigation in the form instead of subgrid as well.
Read more

Ideas about designing a database based web app

I'm creating a web app for my client as a part of my schools final project.
It's a web app where users fill forms (surveys) and after forms are submitted,
values are saved in the database.
There are three types of users: admins, moderators and viewers. Admin's can see the
overview of filled forms, moderators will fill these forms and they also can make edits
to them and get the overview of the forms they've filled. We haven't discussed about the rights of viewers
at this point.
I'm using CodeIgniter as a framework of my project since it comes pretty handy when it comes to database
manipulation and forms. What would be the best way to implement this kind of situation? There are apprx.
4-5 forms (surveys) each moderator will fill. After they've filled them, they only can make edits to that particular form.
So one user can fill each form only once.
I've designed that each of the forms needs one table. So if there is a form (survey) about IT equipment, I will create
a table for IT equipment. User's id number will be saved in to the last column in the table, usually called "user_ID" where I can
make queries based on users and check if user is already filled the particular form.
What about controllers and models? I've thought I could only make one model for inserting and editing the form.
However, is it pretty much the only way to create a controller or method foreach form since there are different types
of form fields to validate based on the form user is actually filling. I've already created a controller for inserting and updating
the IT equipment form and both of these methods are pretty big when it comes to the amount of code, over 200 lines per method.
So that would be a total amount of 2000 lines of code just for inserting and editing all the forms.
What'd you do and how you'd implement this if dealing with similiar kind of project?
Thanks in advance for all the ideas and point of views!
You should take a look into this:
http://cibonfire.com/
It's a really good addon for codeigniter, that allows you to data oriented development.

Store translated versions in database for Joomla component

I'm currently developing my first MVC component for Joomla 3.x. All in all I'm bit struggling with language/translation issues in database.
My problem is that I need to store translated content of user generated content which comes from the backend. For example someone enters a new item in German (stored in database) and needs a translation in another language. How to accomplish that in Joomla? I don't like to generate a new item for every different language when the rest is all the same.
I thought about a table "item" and a table "item_language" with that structure (strongly simplified for viewing purposes):
item
id PRIMARY INT
price DOUBLE(4,2)
item_language
itemid PRIMARY INT
language PRIMARY CHAR(5)
name VARCHAR(50)
In item_language I would like to store the different translated versions. In the language field there would be the region code (eg. de-DE) to identify the language.
My problems:
How to display the different (translated) versions in backend?
Is this the right database model?
Any help is appreciated!
You have really found yourself a nice task for a first component in Joomla!
A rather generalist answer:
The database model seems right. Alternatively you could encode in JSON the language data, but this could make later query operations potentially difficult. This way you will only have one table to work with.
As far as I know (if you are using JModel / JTable to manipulate the data) can't do this directly, as JTable is really only designed to manipulate single tables.
What you can do:
For editing: figure a way to represent this graphically ( for your users to see and edit this one to many relationship) and to post this data (language texts as an array) to JModel. In the model you can maintain the desired relationships and save the data using JTable.
Viewing (without editing) shouldn't be an issue, it would be a simple JOIN.
If you are willing to create a basic component on github, I might even give you a hand with JModel / JTable.
I found a way to deal with the things I needed.
Thanks Valentin Despa for guiding me in the right direction :-).
Here the whole procedure (simplified - validations and exact steps omitted):
Define the form fields in the models/forms/site.xml as normal.
In views/site/tmpl/edit.php add self coded Javascript (based on jQuery) to deal with the fields which have content in multiple languages stored as JSON in database.
Clone the original form element and modify the needed attributes (id, name, ...) to display a special version just for the defined languages. As content - extract the JSON for the needed language from original field content and display.
Hide the original field with Javascript and append the customized versions to DOM.
Afterwards in tables/site.php I read the dynamically generated content withJInput and build together the original field by generating JSON and saving to database.
It's working like expected.

Model with multiple tables

We run two websites, A and B. Each website has its own table, _a_ and _b_ which have exactly the same structure. Yes, I know it's silly, we'll be rewriting them over the course of this year and next.
Using Laravel I need to create a model that will hold both tables content. I don't need any kind of UPDATE or INSERT functionality, I just need to SELECT and use with to access other model information.
Is this possible with Laravel 4.1? I can individually model each table, but that would make it difficult in the future.
I was able to fix this by making using the Repository pattern and merging the results of each model into the get and all functions.

How to process 1 form across 2 controllers/models in MVC (CFWheels)?

I'm an old CFML developer, new to CF on Wheels and MVC programming in general. I'm picking it up pretty quickly, but one thing that isn't evident to me is how one can offer a form to optionally update multiple db table records (models). I'd specifically like to set up a tabbed form for User info and User Profile info, where the former is required and the latter is not. This data is stored in two different one-to-one tables. What's the setup I need in order to call two "new" or "edit" views, run 2 "create" or "update" procedures, affecting two different tables. Or am I thinking about this all wrong.
Update: Adding some more info on what I'm trying to do. To keep it simple, I'll stick to 2 tabs and 2 tables, though I'm really looking at at least 3 in this instance.
So I've got a Users table and a UserProfiles table, and I've got models named User.cfc and UserProfile.cfc that are related 1-to-1, with UserProfile dependent on User. Pretty standard stuff. For each I've got controllers: Users.cfc and UserProfiles.cfc, each of those containing actions. add, edit, create, update, doing the obvious stuff (add and edit display forms). I have partials that display the add/edit form fields for each, so that's already prepared. Now, I want to create what is effectively a single add/edit form that can update both tables at the same time. The tabs don't really matter; effectively it could all be on one page.
So conceptually I'm doing something like:
#startFormTag(action=???)#
#includePartial("form_user_add-edit")#
#includePartial("form_userprofile_add-edit")#
<button type="submit" class="btn">#operation#</button>
#endFormTag()#
Do I need to create a separate controller action that basically combines the create and update actions for two different controllers?
Thanks in advance from a pleased and eager CFWheels newbie...
Brian
If all of the data is related through hasMany or hasOne associations, I'd recommend looking at nested properties.
http://cfwheels.org/docs/1-1/chapter/nested-properties
If you're a newbie though, you may want to refrain from this until you've got something simpler worked out.
I guess you are talking about two models representing these two tables, possibly associated using hasOne. Models allow you to validate data, this makes controller much simpler. This way you could create two forms under two tabs, and keep record's primary key as hidden field. Controller could run the validation and re-display the forms (partials may help)... Hold on, I am just going through the reference.
I realize this answer is pretty generic, as well as your question. I suggest you to go ahead and try something, see how it works.
After that update your question with code samples and ask if you have some specific problems. For example, validation and displaying errors in CFWheels may be a bit tricky.

Resources