public override async Task <XprtResponse> GetByBadgeNumber(GetByBadgeNumberRequest request, ServerCallContext context) { Metadata md = context.RequestHeaders; foreach (var entry in md) { Console.WriteLine(entry.Key + ": " + entry.Value); } var xprt = await _repository.GetXprtByBadge(request.BadgeNumber); return(new XprtResponse() { Xprt = xprt }); throw new Exception("Xprt not found with Badge Number: " + request.BadgeNumber); }
public override async Task <EmployeeResponse> GetByBadgeNumber(GetByBadgeNumberRequest request, ServerCallContext context) { Metadata md = context.RequestHeaders; foreach (var entry in md) { Console.WriteLine(entry.Key + ":" + entry.Value); } foreach (var e in Employees.EmployeeList) { if (e.BadgeNumber == request.BadgeNumber) { return new EmployeeResponse { Employee = e } } ; } throw new Exception("Not found!!"); }
public override async Task <EmployeeResponse> GetByBadgeNumber(GetByBadgeNumberRequest request, ServerCallContext context) { Console.WriteLine($"Service invoked"); Metadata metadata = context.RequestHeaders; foreach (var entry in metadata) { Console.WriteLine(entry.Key + ": " + entry.Value); } var result = Employees.employees.FirstOrDefault(e => e.BadgeNumber == request.BadgeNumber); if (result == null) { throw new Exception($"Employee not found with Badge Number {request.BadgeNumber}"); } return(new EmployeeResponse() { Employee = result }); }
public override async Task <EmployeeResponse> GetByBadgeNumber(GetByBadgeNumberRequest request, ServerCallContext context) { Metadata md = context.RequestHeaders; foreach (var entry in md) { Console.WriteLine(entry.Key + ": " + entry.Value); } foreach (var e in Employees.employees) { if (request.BadgeNumber == e.BadgeNumber) { return(new EmployeeResponse() { Employee = e }); } } throw new Exception("Employee not found with Badge Number: " + request.BadgeNumber); }
/// <summary> /// Unary message: one request <-> one response /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns></returns> public override async Task <EmployeeResponse> GetByBadgeNumber(GetByBadgeNumberRequest request, ServerCallContext context) { var md = context.RequestHeaders; Console.WriteLine("Requested employee with badgenumber: " + request.BadgeNumber); Console.WriteLine("Printing metadata..."); foreach (var entry in md) { Console.WriteLine($"{entry.Key}:{entry.Value}"); } var emp = Employees.employees.Where(x => x.BadgeNumber == request.BadgeNumber).FirstOrDefault(); if (emp == null) { throw new Exception("Employee not found.."); } return(new EmployeeResponse { Employee = emp }); }