Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 private UserProfile AssignEntityToModel(UserProfileEntity userProfileEntity)
 {
     return new UserProfile
     {
         UserId = userProfileEntity.UserId,
         UserName = userProfileEntity.UserName
     };
 }
Ejemplo n.º 3
0
 private void AssignEntityToModel(UserProfileEntity userProfile, UserProfile dbUserProfile)
 {
     dbUserProfile.UserId = userProfile.UserId;
     dbUserProfile.UserName = userProfile.UserName;
 }