Exemplo n.º 1
0
        /* This function was written by Bob van Beek (610685) */
        /// <summary>
        /// Asynchronous method which retrieves a Deliverer with the given identifier.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Filled Deliverer class or null</returns>
        public async Task <Deliverer> GetDelivererById(Guid id)
        {
            try
            {
                _logger.Information($"A request has been made to get a Deliverer with id {id} from the context.");
                Deliverer d = await _deliverersRepo.GetDelivererById(id);

                return(d ?? throw new ArgumentNullException($"Dependency failure: The repository returned null."));
            }
            catch (Exception e) // Error handling
            {
                _logger.Error($"IDeliverersService says: {e.Message} Exception occured on line {new StackTrace(e, true).GetFrame(0).GetFileLineNumber()}.");
                return(null);
            }
        }