// GET: User/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var user = await context.Users .Include(u => u.Employee) .ThenInclude(u => u.Position) .Include(u => u.Role) .FirstOrDefaultAsync(m => m.Id == id); if (user == null) { return(NotFound()); } string dateFormat = config.GetValue <string>("Birthdate:Format"); UserDetailsVM userDetails = new UserDetailsVM { Id = user.Id, Login = user.Login, Role = user.Role.Name, Name = user.Employee.Name, Patronymic = user.Employee.Patronymic, Surname = user.Employee.Surname, Gender = GenderHelper.GetValue(user.Employee.Gender), Position = user.Employee.Position.Name, Birthdate = user.Employee.Birthdate.ToString(dateFormat), Phone = user.Employee.Phone }; return(View(userDetails)); }
public async Task <IActionResult> Index() { var employees = await context.Employees .Include(p => p.Position) .AsNoTracking() .ToListAsync(); string dateFormat = config.GetValue <string>("Birthdate:Format"); IEnumerable <EmployeePreviewVM> employeesPreview = employees.Select(e => new EmployeePreviewVM { Id = e.Id, Name = e.Name, Patronymic = e.Patronymic, Surname = e.Surname, Gender = GenderHelper.GetValue(e.Gender), Position = e.Position.Name, Birthdate = e.Birthdate.ToString(dateFormat), Phone = e.Phone }); return(View(employeesPreview)); }