Is there any way to improve this kind of code? I have converted this from production code for privacy reasons, so there might be some mistakes.
public class AddNewUserDto
{
public bool IsAdmin { get; set; }
public bool IsRead { get; set; }
public bool IsWrite { get; set; }
public string[] GetRolesByDto()
{
List<string> roles = new List<string>();
if (this.IsAdmin)
{
roles.Add(USER_ROLES.ADMIN);
}
if (this.IsRead)
{
roles.Add(USER_ROLES.IsRead);
}
if (this.IsWrite)
{
roles.Add(USER_ROLES.IsWrite);
}
if (this.IsEntityUser)
{
roles.Add(USER_ROLES.IsEntityUser);
}
return roles.ToArray();
}
}
public static class USER_ROLES
{
public const string IsAdmin= "Admin";
public const string IsRead= "Read";
public const string IsWrite= "Write";
public const string IsEntityUser = "EntityUser";
}