有人可以帮助根据用户的角色加密信息吗? 基本上我想要以下内容:如果用户角色=“管理员”,则显示手机号码(Telemovel)435267456.如果用户角色=“用户”,则显示手机号码(Telemovel)xxxxxxxxxx。
我已经使用这个@if(User.IsInRole(“Admin”))来隐藏链接,具体取决于角色和它的工作原理,现在我想加密信息。
模型
public partial class Cliente
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Cliente()
{
this.Reserva = new HashSet<Reserva>();
}
public int ID_Cliente { get; set; }
public string Nome { get; set; }
public string Morada { get; set; }
public string Telemovel { get; set; }
public string Email { get; set; }
public string Contribuinte { get; set; }
public string CartaoCidadao { get; set; }
public System.DateTime DataValidade { get; set; }
public System.DateTime DataNascimento { get; set; }
public System.DateTime DataRegisto { get; set; }
public string País { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Reserva> Reserva { get; set; }
}
查看示例
<div class="form-group">
<label class="col-md-4 control-label">Telemóvel</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span>
<input name="Telemovel" class="form-control" type="text" value="@Model.Telemovel" readonly="readonly">
</div>
</div>
</div>