public string Execute(string[] args) { int id = int.Parse(args[0]); EmployeeFullDto employeeDto = employeeController.GetFullEmployeeInfo(id); StringBuilder sb = new StringBuilder(); sb.a }
public EmployeeFullDto GetFullEmployeeInfo(int employeeId) { Employee employee = context.Employees.Find(employeeId); EmployeeFullDto employeeDto = mapper.Map <EmployeeFullDto>(employee); if (employee == null) { throw new ArgumentException(); } return(employeeDto); }
// helper methods private string generateJwtToken(EmployeeFullDto user) { // generate token that is valid for 7 days var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes("This is Secret Key of Pun's House so dont share it desu ne"); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new[] { new Claim("id", user.Id.ToString()) }), Expires = DateTime.UtcNow.AddDays(7), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); return(tokenHandler.WriteToken(token)); }