Retrieving values of PersonId while using membership - asp.net-mvc-3

I am using ASP.NET Membership in my MVC3 application.
I have used a PersonId variable to declare relation ship between UserId and PersonId to insert values into a different table which contains all the information of the user who has a particular UserId.
With this it is obvious that a person having certain UserId would have a definite PersonId.
Like membership store certain values in the Cookies I want to Store my PersonId in as well.
How can i do that?
The obvious benefit of this approach is that i would save a Database call because the main thing I am using is PersonId.
I want to know the best and most secure way to do that.
Please suggest.
Thanks

The short answer is that you will want to look at :
http://msdn.microsoft.com/en-us/library/2y3fs9xs(v=vs.85).aspx
ASP.NET Profile Properties Overview
http://www.codeproject.com/Articles/281602/ASP-NET-Profile-Provider
ASP.NET Profile Provider

Related

Microservices for shared basic lookup data

I am new to microservices, and I need to create a "Student" service, which will get, save and also adds via a webhook from another thirdparty application
However, one of the fields i need to save is "Subject"
Normally, in SQL i would have a subject table, with things like
ID | Subject
1, Maths
2, English
3, Software
which i can use to populate drop down boxes, and in my Student table, i could have "SubjectId" field
However, if using a microservice... how would i setup my student microservice database so its independent?
then, what if I have a "CollegeCourse" service, which also needs the Subject type?
Should they both have there own 2nd database table, but doesnt that run the risk of a miss match... or maybe a nugGet package and just hardcode some enums which i can share between microservices?
Thank you
I can seem to find any suggestions or answers anywhere for this, but,

Create a new Patient resource referencing user id

I'm trying to create a new FHIR resource Patient using the RESTful API using the XML format. I want to store patient information using the Create method, but in my patient health record I also reference a user (composed of id, username and password) to a patient in the database.
How can I link the id of the user to the Patient resource I'm creating via REST? Is there an XML field where I should place such information?
Is it a good practice to actually use an extension?
It's perfectly reasonable to use an extension for this purpose. If you need the data to be stored in the Patient record, you don't really have a choice. That said, be very cautious about storing password information in the Patient resource - as Patient is going to be sent all over the place. It might be cleaner to store the references to Patient/Practitioner/etc. in your user representation than it is to store security information in your Patient structure. (You can represent the notion of "user" in FHIR using Basic, but we encourage use of non-healthcare-specific standards in this space.)

Generate dynamic form and store the data in Laravel

For a part of my next project I'm looking for the following information.
I'm trying to make an application for something like scouts, all the supervisors will have a user account on the application and the supervisors will be able to manage the members of the scouts. I'm looking for a way to let the supervisor decide what information they would like to store about the member. This will then be converted to a form so they can easily add new members.
What is the best way to make a dynamic form and store the data in a database.
Thanks in advance!
Well there are many ways to do that, so I don't know if this is the best with the little information you give us about your "case scenario".
I'll do create this tables:
forms (hold the form basic info and supervisors reference)
forms_fields (with an Elquent relatinship tipy "belongsTo")
Check Laravel documentation on Eloquent here>

SimpleMembership => Have GUID for the UserId

Unlike many post I've seen online, It's not if I prefer Guid or Int.
Question: I'd like to know HOW to make a Guid for the UserId for the SimpleMembership. If I can't, how to do my own provider code first in order to put, in the end, the UserId in another table (to link a record to the user that did it + I don't want the username (what happens if it changes?)).
My research: I've seen that you would have to subclass and reimplement every methods, but nowhere there was a post that explains how to do it.
The closest post I've seen is : http://www.brianlegg.com/post/2011/05/09/Implementing-your-own-RoleProvider-and-MembershipProvider-in-MVC-3.aspx but it's still with Int as the Identity Pk.
I understand that it may be a feature for VS2012 to do so, but VS2010 does all the tables (User with Guid has Id and all the other tables with Guid columns). I'd still like my UserId with Guid and not int.
Thanks!
I believe you are looking for SimpleGuidMembershipProvider

ASP.NET MVC 3.0 - Maintain model state

Am new to ASP.NET MVC 3.0. Request expert's view on the below mentioned scenario.
I have a customer details page, where only Name is editable. There are 10 other customer properties that are non editable and displayed using SPAN. When user submits the page, I need to update only the Name.
If am using EF, I will have to load customer again, overwrite name and then save. Otherwise I will have to maintain customer model somewhere.
Anyone tried caching model (or viewmodel) using session id? Is it a good practice?
You are almost thinking in right direction.
If am using EF, I will have to load customer again, overwrite name and then save. Otherwise I will have to maintain customer model somewhere.
In Update Method **Load Customer again and update name Only as required and then save
**For 2 reasons
The first and most important rule is 'don't trust user data'. and
Concurrency and to avoid saving old data. See this example
Instead of using Session, I will suggest to use Hidden Field for record LastUpdateDateTime and Customer ID which will be posted back in the model to retrieve record and verify LastUpdatedtime with database record
Tipically, you should use a view model different than the database model. Having said that,in your current case the situation is very simple, submit only the name to the controller and then set the Name property of the object you get from EF with the submitted name.
Caching the view model or the model isn't your concern. The database model caching is handled by EF, your problem is mainly a lack of clear application layering. IN fact I strongly suggest to learn a bit more about the MVC pattern, basic application architecture (2-3 layering) and when and how to use a OR\M (which EF is).
use hidden inputs for other properties in your form. In that way you can get all properties binded to your EF entity and you dont need to get entity again from db.
#Html.DisplayFor(model=>model.x)
#Html.HiddenFor(model=>model.x)
or you can serialize the entity(if you use POCO entities) and set to hidden input. When you post back you should deserialize the entity.
My choice is always first one. :)

Resources