public ActionResult Create(Inquilino e) { Persona p = repositorioPersona.getByDniEmail(e.Persona.Dni, e.Persona.Email); if (p != null) { e.Persona = p; } else { e.Persona.TipoPersona = repositorioTipoPersona.getById(e.Persona.TipoPersona.Id); e.Persona.TipoPersonaId = e.Persona.TipoPersona.Id; e.Persona.Password = ""; //Fuente: https://es.coredump.biz/questions/4538894/get-index-of-a-keyvalue-pair-in-a-c-dictionary-based-on-the-value e.Persona.Rol = Persona.ObtenerRoles().First(kvp => kvp.Value.Equals("Inquilino")).Key; e.Persona.Avatar = ""; e.Persona.Id = repositorioPersona.Create(e.Persona); if (e.Persona.AvatarFile != null) { e.Persona.Avatar = utils.uploadFile(e.Persona); } repositorioPersona.Edit(e.Persona); } try { e.Activo = true; repositorio.Create(e); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }