/// <summary>
        /// Creates the Profile from the specified collection.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <returns></returns>
        public IProfile Create(SettingsPropertyValueCollection collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            var profile = new Profile
                          {
                              ProfileId = (int) collection["ProfileId"].PropertyValue,
                              UserId = (int) collection["UserId"].PropertyValue,
                              ReceiveEmailNotification = (bool) collection["ReceiveEmailNotification"].PropertyValue,
                              PersonId = (int) collection["PersonId"].PropertyValue,
                              IsActive = (bool) collection["IsActive"].PropertyValue,
                              IsDisabled = (bool) collection["IsDisabled"].PropertyValue,
                              IsValidated = (bool) collection["IsValidated"].PropertyValue,
                              DateCreated = (DateTime) collection["DateCreated"].PropertyValue,
                              DateModified = (DateTime) collection["DateModified"].PropertyValue
                          };

            if (collection["Person"].PropertyValue != null)
            {
                profile.Person = (Person)collection["Person"].PropertyValue;
            }

            return profile;
        }
Exemplo n.º 2
0
        public static Profile ToModel(this Data.Entities.Profile profile)
        {
            var profileModel = new Profile();

            if (profile == null)
            {
                return profileModel;
            }

            profileModel.ProfileId = profile.ProfileId;
            profileModel.PersonId = profile.PersonId;
            profileModel.ReceiveEmailNotification = profile.ReceiveEmailNotification;
            profileModel.IsActive = profile.IsActive;
            profileModel.IsDisabled = profile.IsDisabled;
            profileModel.IsValidated = profile.IsValidated;
            profileModel.UserId = profile.UserId;
            profileModel.DateModified = profile.DateModified;
            profileModel.DateCreated = profile.DateCreated;

            if (profile.Person != null)
            {
                profileModel.Person = profile.Person.ToModel();
            }

            return profileModel;
        }