public override void OnNext(ExternalVisitor value) { var externalVisitor = value; var externalVisitorListItem = _externalVisitors.FirstOrDefault(e => e.Id == externalVisitor.Id); if (externalVisitorListItem == null) { _externalVisitors.Add(externalVisitor); OutputFormatter.ChangeOutputTheme(OutputFormatter.TextOutputTheme.Security); Console.WriteLine($"Security notification: Visitor Id({externalVisitor.Id}), FirstName({externalVisitor.FirstName}), LastName({externalVisitor.LastName}), entered the building, DateTime({externalVisitor.EntryDateTime.ToString("dd MMM yyyy hh:mm:ss tt")})"); OutputFormatter.ChangeOutputTheme(OutputFormatter.TextOutputTheme.Normal); Console.WriteLine(); } else { if (externalVisitor.InBuilding == false) { //update local external visitor list item with data from the external visitor object passed in from the observable object externalVisitorListItem.InBuilding = false; externalVisitorListItem.ExitDateTime = externalVisitor.ExitDateTime; Console.WriteLine($"Security notification: Visitor Id({externalVisitor.Id}), FirstName({externalVisitor.FirstName}), LastName({externalVisitor.LastName}), exited the building, DateTime({externalVisitor.ExitDateTime.ToString("dd MMM yyyy hh:mm:ss tt")})"); Console.WriteLine(); } } }
public override void OnNext(ExternalVisitor value) { var externalVisitor = value; if (externalVisitor.EmployeeContactId == _employee.Id) { var externalVisitorListItem = _externalVisitors.FirstOrDefault(e => e.Id == externalVisitor.Id); if (externalVisitorListItem == null) { _externalVisitors.Add(externalVisitor); OutputFormatter.ChangeOutputTheme(OutputFormatter.TextOutputTheme.Employee); Console.WriteLine($"{_employee.FirstName + " " + _employee.LastName}, your visitor has arrived. Visitor ID({externalVisitor.Id}), FirstName({externalVisitor.FirstName}), LastName({externalVisitor.LastName}), entered the building, DateTime({externalVisitor.EntryDateTime.ToString("dd MMM yyyy hh:mm:ss")})"); OutputFormatter.ChangeOutputTheme(OutputFormatter.TextOutputTheme.Normal); Console.WriteLine(); } else { if (externalVisitor.InBuilding == false) { //update local external visitor list item with data from the external visitor object passed in from the observable object externalVisitorListItem.InBuilding = false; externalVisitorListItem.ExitDateTime = externalVisitor.ExitDateTime; } } } }