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

            if (userPostModel.UserRole == "UserManager")
            {
                rol = WebApplication3.Models.UserRole.UserManager;
            }
            else if (userPostModel.UserRole == "Admin")
            {
                rol = WebApplication3.Models.UserRole.Admin;
            }

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

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

            return(new User
            {
                FirstName = userPostModel.FirstName,
                LastName = userPostModel.LastName,
                Username = userPostModel.UserName,
                Email = userPostModel.Email,
                Password = ComputeSha256Hash(userPostModel.Password),
                RegistrationDate = DateTime.Now
            });
        }