Пример #1
0
        public static User ToUser(UserPostModel user)
        {
            UserRole role = Models.UserRole.Regular;

            if (user.UserRole == "Moderator")
            {
                role = Models.UserRole.Moderator;
            }
            else if (user.UserRole == "Admin")
            {
                role = Models.UserRole.Admin;
            }

            return(new User
            {
                FirstName = user.FirstName,
                LastName = user.LastName,
                Username = user.Username,
                Email = user.Email,
                Password = ComputeSha256Hash(user.Password),
                UserRole = role
            });
        }
Пример #2
0
        public static User ToUser(UserPostModel user)
        {
            UserRole role = Models.UserRole.Client;

            if (user.UserRole == "FOStaff")
            {
                role = Models.UserRole.FOStaff;
            }
            else if (user.UserRole == "Admin")
            {
                role = Models.UserRole.Admin;
            }

            return(new User
            {
                FirstName = user.FirstName,
                LastName = user.LastName,
                Username = user.Username,
                Email = user.Email,
                Password = ComputeSha256Hash(user.Password),
                UserRole = role,
                CreatedAt = DateTime.Now
            });
        }