Can anyone help encrypt information according to the user's role? Basically I want the following: if the user's function is="Admin" the Mobile number appears 435267456. If the User's function is="User" the Mobile number appears xxxxxxxxxx.
I used this if (User.IsInRole ("Admin")) to hide links depending on the function and it works, now I want to encrypt the information but I can not.
Model
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; }
}
View
<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>
Controller
// GET: Clientes/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Cliente cliente = db.Cliente.Find(id);
if (cliente == null)
{
return HttpNotFound();
}
ViewBag.ListaReservas = db.Reserva.Include(p=> p.Cliente).Where(p => p.ID_Cliente == cliente.ID_Cliente);
return View(cliente);
}