1

Hi I am using identity in my project and i can easily get the user name of the user on _layout page with the below code part :

@User.Identity.GetUserName

But i have more properties to get. Here is my extended user class..

using Microsoft.AspNet.Identity.EntityFramework;
using ModulericaV1.Areas.Hr.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;

namespace ModulericaV1.Models
{
    public class ApplicationUser : IdentityUser
    {
        public ApplicationUser()
            : base()
        {
            this.Groups = new HashSet<ApplicationUserGroup>();
        }

        [Required]
        public string FirstName { get; set; }

        [Required]
        public string LastName { get; set; }

        [Required]
        public string Email { get; set; }

        public virtual ICollection<ApplicationUserGroup> Groups { get; set; }

        public int? HrPersonId { get; set; }
        public virtual HrPerson HrPerson { get; set; }

    }
}

I am trying to implement method such as GetUserName but i really could not start since i could not find the definition.

Here is the definition when i debug the code. But i am missing something.

namespace Microsoft.AspNet.Identity
{
    public static class IdentityExtensions
    {
        public static string FindFirstValue(this ClaimsIdentity identity, string claimType);
        public static string GetUserId(this IIdentity identity);
        public static string GetUserName(this IIdentity identity);
    }
}

My main question is : how can i write the method to get email or HrPerson properties.

umki
  • 769
  • 13
  • 31

0 Answers0