Exemplo n.º 1
0
        public static User GetUserFromModel(UserModel model, DbContextHelper db)
        {
            if (model == null)
            {
                return(null);
            }

            User user = new User
            {
                FirstName      = model.FirstName,
                LastName       = model.LastName,
                ScreenName     = model.ScreenName,
                Email          = model.Email,
                Link           = model.Link,
                AccessToken    = model.AccessToken,
                FacebookId     = model.FacebookId,
                UserStatusEnum = model.UserStatus,
                LastAccessed   = model.LastAcecssed,
                Created        = model.Created,
                Id             = model.Id,
                Roles          = ManageRoleModelHelper.GetRolesFromModel(model.Roles, db)
            };

            return(user);
        }
Exemplo n.º 2
0
        public static UserModel GetModelFromUser(User user)
        {
            if (user == null)
            {
                return(null);
            }

            var roles      = user.Roles.ToList().GetRoleModelsFromRoles();
            var ministries = user.Ministries.ToList().GetMinstryModelsFromMinistries();

            return(new UserModel
            {
                FirstName = user.FirstName,
                LastName = user.LastName,
                ScreenName = user.ScreenName,
                Email = user.Email,
                Link = user.Link,
                AccessToken = user.AccessToken,
                FacebookId = user.FacebookId,
                UserStatus = user.UserStatusEnum,
                LastAcecssed = user.LastAccessed,
                Created = user.Created,
                Id = user.Id,
                IdKey = user.IdKey,
                Roles = roles,
                MultiSelectRoleList = ManageRoleModelHelper.GetMultiSelectedRoles(roles),
                Ministries = ministries,
                MultiSelectMinistryList = ManageMinistryModelHelper.GetMultiSelectedMinistries(ministries),
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates the model for the Manage.UserController.Add post action
        /// </summary>
        /// <returns></returns>
        public static void UpdateUserModelForAdd(this UserModel model)
        {
            Guid userIdKey = ManageUserModelHelper.GetFormsAuthenticationTicket().IdKey();

            model.PageTitle = "Holy Angels Add New System User";
            model.SubTitle  = "New System User";
            model.UserIdKey = userIdKey;

            model.MultiSelectRoleList     = ManageRoleModelHelper.GetMultiSelectedRoles();
            model.MultiSelectMinistryList = ManageMinistryModelHelper.GetMultiSelectedMinistries();

            model.MetaDescription = "";
            model.MetaKeywords    = "";
            model.MetaSubject     = "";
        }
Exemplo n.º 4
0
        private static User CreateNewUserFromModel(UserModel model, DbContextHelper db)
        {
            if (model == null)
            {
                return(null);
            }

            User user = db.Users.Create();

            user.FirstName      = model.FirstName;
            user.LastName       = model.LastName;
            user.ScreenName     = model.ScreenName;
            user.Email          = model.Email;
            user.UserStatusEnum = model.UserStatus;
            user.LastAccessed   = model.LastAcecssed;
            user.Created        = model.Created;
            user.IdKey          = model.IdKey;

            var roles = ManageRoleModelHelper.GetRolesFromModel(model.Roles, db);

            if (roles.Count > 0)
            {
                user.Roles = new List <Role>();
                foreach (var role in roles)
                {
                    user.Roles.Add(role);
                }
            }

            var ministries = ManageMinistryModelHelper.GetMinistriesFromModel(model.Ministries, db);

            if (ministries.Count > 0)
            {
                user.Ministries = new List <Ministry>();
                foreach (var ministry in ministries)
                {
                    user.Ministries.Add(ministry);
                }
            }

            return(user);
        }