public void Save(UserProfileEntity userProfileEntity) { if (userProfileEntity == null) { throw new ArgumentNullException( "userProfileEntity", "Can't save null to the user profiles."); } // Make sure it doesn't exist. If it does then // you're doing it wrong. var existingUserProfile = GetUser(userProfileEntity.UserName); if (existingUserProfile != null) { // Nothing to do. return; } var userProfile = AssignEntityToModel(userProfileEntity); this .Context .UserProfiles .Add(userProfile); this.Context.SaveChanges(); userProfileEntity.UserId = userProfile.UserId; }
private UserProfile AssignEntityToModel(UserProfileEntity userProfileEntity) { return new UserProfile { UserId = userProfileEntity.UserId, UserName = userProfileEntity.UserName }; }
private void AssignEntityToModel(UserProfileEntity userProfile, UserProfile dbUserProfile) { dbUserProfile.UserId = userProfile.UserId; dbUserProfile.UserName = userProfile.UserName; }