Exemple #1
0
        public IHttpActionResult GetUserByEmail(string email)
        {
            UserSecurityToken userdetails = null;

            using (var ctx = new InventoryManagementEntities())
            {
                User user = ctx.Users.FirstOrDefault(c => c.Email == email);
                if (user != null)
                {
                    userdetails = new UserSecurityToken
                    {
                        Id         = user.ID,
                        FirstName  = user.FirstName,
                        LastName   = user.LastName,
                        MiddleName = user.MiddleName,
                        Email      = user.Email,
                        Role       = RoleType.GetRoleType(ctx.aspnet_UsersInRoles_GetRolesForUser(user.aspnet_Users.aspnet_Applications.ApplicationName, user.Email)?.FirstOrDefault())
                    };
                }
            }
            return(Ok(userdetails));
        }