3
I have a class of service and in it I have the User responsible for the service, which is a user of the IdentityUser
.
Remembering that I changed the Identity id from string to "Int", that’s all.
I can register normally, however, when I edit, it lists users, but does not bring set the user who is already registered in the service.
Entity:
[Table("Atendimentos")]
public class Atendimento
{
[Key]
public int AtendimentoId { get; set; }
public int UsuarioId { get; set; }
[Display(Name = "Responsável pelo atendimento")]
public virtual Usuario Usuario { get; set; }
}
Controller:
ViewBag.UsuarioId = new SelectList(db.Users.Select(x => new { UsuarioId = x.Id, Nome = x.Nome + " " + x.Sobrenome }), "UsuarioId", "Nome");
View:
@Html.DropDownList("UsuarioId", null, htmlAttributes: new { @class = "form-control" })
I have tried to put the "User" property for "Id" feathers, because Identity only uses "Id", even though it didn’t work.
It worked perfectly! Thank you very much for the reply.
– João Chagas