/* This method was written by Bob van Beek (610685) */ /// <summary> /// Asynchronous method which retrieves the current Delivery of a Deliverer from the context. /// </summary> /// <param name="delivererId"></param> /// <returns></returns> public async Task <Delivery> GetCurrentDeliveryForDeliverer(Guid delivererId) { try { _logger.Information($"A request has been made to get the current Delivery for Deliverer {delivererId} from the context."); Delivery d = await _deliveriesRepository.GetCurrentDeliveryForDeliverer(delivererId); if (d == null) { throw new ArgumentNullException("Dependency failure: The repository returned null"); } Delivery d2 = await AggregateLocations(d); return(d2 ?? throw new ArgumentNullException("Dependency failure: AggregateLocations returned null.")); } catch (Exception e) // Error handling { _logger.Error($"IDeliveriesService says: {e.Message} Exception occured on line {new StackTrace(e, true).GetFrame(0).GetFileLineNumber()}."); return(null); } }