public static string GenerateToken(AuthUserOutputModel user)
        {
            try
            {
                var tokenExpiryTime = 20;
                var now             = DateTime.UtcNow;

                var securityTokenDescriptor = new SecurityTokenDescriptor()
                {
                    Subject = new ClaimsIdentity(new List <Claim>()
                    {
                        new Claim(ClaimType.Id, user.Id.ToString()),
                    }),
                    SigningCredentials = new SigningCredentials(
                        new SymmetricSecurityKey(Encoding.UTF8.GetBytes(communicationKey)),
                        SecurityAlgorithms.HmacSha256Signature),
                    Expires = now.AddMinutes(tokenExpiryTime)
                };

                var tokenHandler = new JwtSecurityTokenHandler();
                var plainToken   = tokenHandler.CreateToken(securityTokenDescriptor);
                return(tokenHandler.WriteToken(plainToken));
            }
            catch (Exception ex)
            {
                //throw ex;
                return(ex.Message);
            }
        }
        public async Task <AuthUserOutputModel> AuthenticateUser(AuthUserInputModel authUser)
        {
            try
            {
                var tokenDetails = new AuthUserOutputModel();
                var result       = await userRepository.GetByCondition(item => item.LoginName == authUser.LoginName && item.Password == authUser.Password);

                var user = new User();
                foreach (var item in result)
                {
                    user = item;
                }

                if (user.LoginName != null)
                {
                    tokenDetails       = mapper.Map <AuthUserOutputModel>(user);
                    tokenDetails.Token = AuthModule.GenerateToken(tokenDetails);
                }
                return(tokenDetails);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }