Beispiel #1
0
        /// <summary>
        /// Creates the user role view.
        /// </summary>
        /// <param name="userDetail">The user detail.</param>
        /// <param name="userAppCollection">The user application collection.</param>
        /// <param name="appRoleCollection">The application role collection.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// userDetail
        /// or
        /// userAppCollection
        /// or
        /// appRoleCollection
        /// </exception>
        public IUsersView CreateUserRoleViewList(IUserDetail userDetail, IList <IUserAppRole> userAppCollection,
                                                 IList <IAppRole> appRoleCollection)
        {
            if (userDetail == null)
            {
                throw new ArgumentNullException(nameof(userDetail));
            }

            if (userAppCollection == null)
            {
                throw new ArgumentNullException(nameof(userAppCollection));
            }

            if (appRoleCollection == null)
            {
                throw new ArgumentNullException(nameof(appRoleCollection));
            }

            var appRoleDropDown = GetDropDownList.AppRoleListItems(appRoleCollection, -1);


            var returnView = new UsersView
            {
                UserId            = userDetail.UserId,
                Username          = userDetail.Username,
                IsUserVerified    = userDetail.IsUserVerified,
                FirstName         = userDetail.FirstName,
                LastName          = userDetail.LastName,
                Email             = userDetail.Email,
                AppRoleCollection = userAppCollection,
                RoleDropDown      = appRoleDropDown
            };

            return(returnView);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the edit user view.
        /// </summary>
        /// <param name="userDetail">The user detail.</param>
        /// <param name="companyCollection">The company collection.</param>
        /// <param name="appRoleCollection">The application role collection.</param>
        /// <param name="processingMessage">The processing message.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// userDetail
        /// or
        /// companyCollection
        /// or
        /// appRoleCollection
        /// </exception>
        public IUserViewModel CreateEditUserView(IUserViewModel userDetail, IList <ICompanyDetail> companyCollection,
                                                 IList <IAppRole> appRoleCollection, string processingMessage)
        {
            if (userDetail == null)
            {
                throw new ArgumentNullException(nameof(userDetail));
            }

            if (companyCollection == null)
            {
                throw new ArgumentNullException(nameof(companyCollection));
            }

            if (appRoleCollection == null)
            {
                throw new ArgumentNullException(nameof(appRoleCollection));
            }

            var companyDropDown = GetDropDownList.CompanyListItems(companyCollection, -1);

            var appRoleDropDown = GetDropDownList.AppRoleListItems(appRoleCollection, -1);

            userDetail.CompanyDropDown   = companyDropDown;
            userDetail.RoleDropDown      = appRoleDropDown;
            userDetail.ProcessingMessage = processingMessage;

            return(userDetail);
        }
Beispiel #3
0
        /// <summary>
        /// Creates the user role view.
        /// </summary>
        /// <param name="appRoleCollection">The application role collection.</param>
        /// <param name="userDetail">The user detail.</param>
        /// <param name="loggedInUsername">The logged in username.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">appRoleCollection</exception>
        public IUserAppRoleView CreateUserRoleView(IList <IAppRole> appRoleCollection, IUserDetail userDetail, string loggedInUsername)
        {
            if (appRoleCollection == null)
            {
                throw new ArgumentNullException(nameof(appRoleCollection));
            }

            var appRoleDropDown = GetDropDownList.AppRoleListItems(appRoleCollection, -1);


            var returnView = new UserAppRoleView
            {
                AppRoleCollection = appRoleDropDown,
                Username          = userDetail.Username,
                UserId            = userDetail.UserId,
                CreateByUsername  = loggedInUsername
            };

            return(returnView);
        }
Beispiel #4
0
        /// <summary>
        /// Creates the edit user view.
        /// </summary>
        /// <param name="userDetail">The user detail.</param>
        /// <param name="companyCollection">The company collection.</param>
        /// <param name="appRoleCollection">The application role collection.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// userDetail
        /// or
        /// companyCollection
        /// or
        /// appRoleCollection
        /// </exception>
        public IUserViewModel CreateEditUserView(IUserDetail userDetail, IList <ICompanyDetail> companyCollection,
                                                 IList <IAppRole> appRoleCollection)
        {
            if (userDetail == null)
            {
                throw new ArgumentNullException(nameof(userDetail));
            }

            if (companyCollection == null)
            {
                throw new ArgumentNullException(nameof(companyCollection));
            }

            if (appRoleCollection == null)
            {
                throw new ArgumentNullException(nameof(appRoleCollection));
            }

            var companyDropDown = GetDropDownList.CompanyListItems(companyCollection, -1);

            var appRoleDropDown = GetDropDownList.AppRoleListItems(appRoleCollection, -1);


            var returnView = new UserViewModel
            {
                UserId          = userDetail.UserId,
                Username        = userDetail.Username,
                IsUserVerified  = userDetail.IsUserVerified,
                FirstName       = userDetail.FirstName,
                LastName        = userDetail.LastName,
                Email           = userDetail.Email,
                CompanyDropDown = companyDropDown,
                RoleDropDown    = appRoleDropDown
            };

            return(returnView);
        }
Beispiel #5
0
        /// <summary>
        /// Gets the edit user application role view.
        /// </summary>
        /// <param name="userAppRole">The user application role.</param>
        /// <param name="roleCollection">The role collection.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// userAppRole
        /// or
        /// roleCollection
        /// </exception>
        public IUserAppRoleView GetEditUserAppRoleView(IUserAppRole userAppRole, IList <IAppRole> roleCollection)
        {
            var appRoleName = string.Empty;

            if (userAppRole == null)
            {
                throw new ArgumentNullException(nameof(userAppRole));
            }

            if (roleCollection == null)
            {
                throw new ArgumentNullException(nameof(roleCollection));
            }

            var appRoleDropDown = GetDropDownList.AppRoleListItems(roleCollection, userAppRole.AppRoleId);

            foreach (var item in roleCollection)
            {
                if (item.AppRoleId == userAppRole.AppRoleId)
                {
                    appRoleName = item.Action;
                }
            }

            var result = new UserAppRoleView
            {
                AppRoleId         = userAppRole.AppRoleId,
                Username          = userAppRole.Username,
                CreateByUsername  = userAppRole.CreateByUsername,
                DateCreated       = userAppRole.DateCreated,
                AppRoleCollection = appRoleDropDown,
                AppRoleName       = appRoleName
            };

            return(result);
        }