private TrackingResponseDto CreateTrackingNotificationImpl(IRepositoryLocator locator, TrackingNotificationDto dto)
        {
            var response = new TrackingResponseDto
            {
              Accepted = false,
              NotificationId = dto.Id,
              DispatchNoteId = 0,
              Error = string.Empty
            };

              // see if we can fetch dispatch note
              var dispatchNote =
            locator.FindAll<DispatchNote>()
               .FirstOrDefault(d => d.TruckReg.Equals(dto.TruckRegistration, StringComparison.InvariantCultureIgnoreCase));

              if (dispatchNote == null)
              {
            response.Error = "DispatchNote was not found with Truck Registration: " + dto.TruckRegistration;
            return response;
              }

              response.DispatchNoteId = dispatchNote.Id;

              // dispatch found and it is valid
              response = dispatchNote.CreateTrackingNotification(locator, dto, response);
              if (response.Accepted)
              {
            var dispatchEvent = Mapper.Map<DispatchEventBase>(dispatchNote);
            CreateDispatchEvent(dispatchEvent);
              }
              return response;
        }
        private TrackingResponseDto CreateTrackingNotificationImpl(IRepositoryLocator locator, TrackingNotificationDto dto)
        {
            var response = new TrackingResponseDto
            {
                Accepted       = false,
                NotificationId = dto.Id,
                DispatchNoteId = 0,
                Error          = string.Empty
            };

            // see if we can fetch dispatch note
            var dispatchNote =
                locator.FindAll <DispatchNote>()
                .FirstOrDefault(d => d.TruckReg.Equals(dto.TruckRegistration, StringComparison.InvariantCultureIgnoreCase));

            if (dispatchNote == null)
            {
                response.Error = "DispatchNote was not found with Truck Registration: " + dto.TruckRegistration;
                return(response);
            }

            response.DispatchNoteId = dispatchNote.Id;

            // dispatch found and it is valid
            response = dispatchNote.CreateTrackingNotification(locator, dto, response);
            if (response.Accepted)
            {
                var dispatchEvent = Mapper.Map <DispatchEventBase>(dispatchNote);
                CreateDispatchEvent(dispatchEvent);
            }
            return(response);
        }
        public TrackingResponseDto CreateTrackingNotification(IRepositoryLocator locator, TrackingNotificationDto dto, TrackingResponseDto response)
        {
            if (!(DispatchNoteStatus == New |
                  DispatchNoteStatus == InTransit))
            {
                response.Error = "DispatchNote was found but its status was not new or in-transit, it was: " + DispatchNoteStatus;
                return(response);
            }

            if (DispatchNoteStatus == New)
            {
                DispatchNoteStatus = InTransit;
            }

            LastUpdate = DateTime.Now;
            var trackingNotification = TrackingNotification.Create(locator, dto, this);

            LastTrackingNotification = trackingNotification;
            response.Accepted        = true;
            return(response);
        }