public EmployeePersonalDto EmployeePersonalInfo(int id) { Employee employee = this.dbContext.Employees.Find(id); if (employee == null) { throw new ArgumentException($"Employee with id {id} does not exist!"); } EmployeePersonalDto employeePersonalDto = Mapper.Map <EmployeePersonalDto>(employee); return(employeePersonalDto); }
public string Execute(string[] arguments) { if (arguments.Length != 1) { throw new ArgumentException("Invalid id!"); } int id = int.Parse(arguments[0]); EmployeePersonalDto epDto = this.employeeService.EmployeePersonalInfo(id); StringBuilder sb = new StringBuilder(); sb.AppendLine($"ID: {epDto.Id} - {epDto.FirstName} {epDto.LastName} - ${epDto.Salary:F2}"); sb.AppendLine($"Birthday: {epDto.Birthday.Value.ToString("dd-MM-yyyy")}"); sb.AppendLine($"Address: {epDto.Address}"); return(sb.ToString().Trim()); }
//<employeeId> public string Execute(params string[] args) { int employeeId = int.Parse(args[0]); EmployeePersonalDto epDto = employeeService.PersonalById(employeeId); string birthday = "[no birthday specified]"; if (epDto.Birthday != null) { birthday = epDto.Birthday.Value.ToString("dd-MM-yyyy"); } string address = epDto.Address ?? "[no address specified]"; string result = $"ID: {employeeId} - {epDto.FirstName} {epDto.LastName} - ${epDto.Salary:f2}" + Environment.NewLine + $"Birthday: {birthday}" + Environment.NewLine + $"Address: {address}"; return(result); }