/* This method was written by Bob van Beek (610685) */ /// <summary> /// Public method that updates a Delivery record in the context. /// </summary> /// <param name="delivery"></param> /// <returns></returns> public async Task <Delivery> UpdateDelivery(Delivery delivery) { try { _logger.Information($"A request has been made to update a Delivery record with id {delivery.Id} in the context."); Delivery d = _deliveriesRepository.UpdateDelivery(delivery); 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); } }