示例#1
0
        public static User ToUser(UserPostModel userModel)
        {
            //UserRole rol = Lab3.Models.UserRole.Regular;

            //if (userModel.UserRole == "UserManager")
            //{
            //    rol = Lab3.Models.UserRole.UserManager;
            //}
            //else if (userModel.UserRole == "Admin")
            //{
            //    rol = Lab3.Models.UserRole.Admin;
            //}

            return(new User
            {
                FirstName = userModel.FirstName,
                LastName = userModel.LastName,
                Username = userModel.UserName,
                Email = userModel.Email,
                Password = ComputeSha256Hash(userModel.Password)
            });
        }
示例#2
0
        public static User ToUser(UserPostModel userModel)
        {
            UserRole rol = Lab3.Models.UserRole.Regular;

            if (userModel.UserRole == "UserManager")
            {
                rol = Lab3.Models.UserRole.UserManager;
            }
            else if (userModel.UserRole == "Admin")
            {
                rol = Lab3.Models.UserRole.Admin;
            }

            return(new User
            {
                FirstName = userModel.FirstName,
                LastName = userModel.LastName,
                Username = userModel.UserName,
                Email = userModel.Email,
                Password = userModel.Password,
                UserRole = rol
            });
        }