//[EnumDataType(typeof(UserRole))] // public string UserRole { get; set; } public static User ToUser(UserPostDTO user) { //UserRole UserRole = UserRole.Regular; //if (user.UserRole == "UserManager") //{ // UserRole = UserRole.UserManager; //} //else if (user.UserRole == "Admin") //{ // UserRole = UserRole.Admin; //} return(new User { FirstName = user.FirstName, LastName = user.LastName, Username = user.Username, Email = user.Email, Password = ComputeSha256Hash(user.Password), RegistrationDate = DateTime.Now }); }
public static User ToUser(UserPostDTO user) { UserRole UserRole = UserRole.Regular; if (user.UserRole == "UserManager") { UserRole = UserRole.UserManager; } else if (user.UserRole == "Admin") { UserRole = UserRole.Admin; } return(new User { FirstName = user.FirstName, LastName = user.LastName, Username = user.Username, Email = user.Email, Password = ComputeSha256Hash(user.Password), UserRole = UserRole }); }