/* This method was written by Bob van Beek (610685) */ /// <summary> /// Asynchronous method which retrieves all deliveries for an Deliverer from the context. /// </summary> /// <param name="delivererId"></param> /// <returns></returns> public async Task <List <Delivery> > GetDeliveriesForUser(Guid delivererId) { try { _logger.Information($"A request has been made to get all Delivery records for Deliverer {delivererId} from the context."); List <Delivery> deliveries = await _deliveriesRepository.GetDeliveriesForUser(delivererId); foreach (Delivery d in deliveries) { await AggregateLocations(d); } return(deliveries != null && deliveries.Count > 0 ? deliveries : throw new ArgumentNullException("Dependency failure: The repository 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); } }