示例#1
0
        public void ReportParcelDelivery(string parcelID)
        {
            Data.Parcel dataParcel;
            try
            {
                logger.LogDebug($"getting parcel {parcelID} from repo");
                dataParcel = parcelRepository.GetByTrackingId(parcelID);
            }
            catch (DataAccessLayerException e)
            {
                throw new BusinessLayerException("DAL Exception", e);
            }

            Parcel businessParcel = this.mapper.Map <Parcel>(dataParcel);

            businessParcel.ReportDelivery();
            Data.Parcel mappedParcel = this.mapper.Map <Data.Parcel>(businessParcel);

            try
            {
                logger.LogInformation($"updating parcel {parcelID}");
                parcelRepository.Delivered(mappedParcel);

                List <Data.Webhook> dataWebhooks = webhookRepository.GetByTrackingId(parcelID);
                List <Webhook>      webhooks     = new List <Webhook>();
                dataWebhooks.ForEach(hook => webhooks.Add(this.mapper.Map <Webhook>(hook)));
                NotifyAllSubscribers(webhooks);
                DeleteAllSubscribers(webhooks);
            }
            catch (DataAccessLayerException e)
            {
                throw new BusinessLayerException("DAL Exception", e);
            }
        }