public DestinationPresenter(IDestinationView view, ProductModel selectedProduct)
        {
            _view = view;

            SelectedProduct = selectedProduct;

            _destinationMapper = new DestinationMapper();

            _transportMapper = new TransportMapper();

            _productMapper = new ProductMapper();

            _orderMapper = new OrderMapper();

            _orderStatusMapper = new OrderStatusMapper();

            _unitOfWork = new UnitOfWork(new ApplicationContext());

            destinationService = new DestinationService(_unitOfWork);

            transportService = new TransportService(_unitOfWork);

            orderService = new OrderService(_unitOfWork);

            OrderStatusService = new OrderStatusService(_unitOfWork);

            destinations = destinationService.GetAllDestinations().Select(dest => _destinationMapper.FromDomainToModel(dest)).ToList();

            _view.DisplayData(destinations);

            _view.DestinationSelected += BeginOrderCreation;
        }
Beispiel #2
0
        private DestinationService GetDestinationService()
        {
            var userId  = User.Identity.GetUserId();
            var service = new DestinationService(userId);

            return(service);
        }
        public void ShouldRetrunDestinationVmForEdit()
        {
            var destination = new Destination()
            {
                Id              = 1,
                CountryId       = 1,
                Name            = "test",
                CreatedDateTime = DateTime.Now
            };
            var countries = new List <Country>()
            {
                new Country()
                {
                    Id = 1, Name = "test", SubsistanceAllowenceId = 1
                }
            };
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper   = config.CreateMapper();
            var destRepo = new Mock <IDestinationRepository>();

            destRepo.Setup(d => d.GetDestinationById(1)).Returns(destination);
            destRepo.Setup(d => d.GetAllCountries()).Returns(countries.AsQueryable());
            var destServ = new DestinationService(destRepo.Object, mapper);

            var destVmForEdit = destServ.GetDestinationForEdit(1);

            destVmForEdit.Should().BeOfType(typeof(NewDestinationVm));
            destVmForEdit.Should().NotBeNull();
            destVmForEdit.Countries.Should().AllBeOfType(typeof(CountryVm));
            destVmForEdit.Countries.Should().HaveCount(1);
        }
        public void GetAllDestinations_ShouldReturn_All_DestViewModels()
        {
            var destRepoBuilder = new DestinationsRepositoryBuilder();
            var destRepo        = destRepoBuilder
                                  .WithAll()
                                  .Build();

            var sut = new DestinationService(destRepo, null, null, null, null, null, null, this.Mapper);

            var actual   = sut.GetAllDestinations();
            var expected = new List <DestViewModel>
            {
                new DestViewModel {
                    Id = "1"
                }, new DestViewModel {
                    Id = "2"
                },
                new DestViewModel {
                    Id = "3"
                }, new DestViewModel {
                    Id = "4"
                }
            }.AsQueryable();

            Assert.Equal(expected, actual, new DestViewModelComparer());

            destRepoBuilder.DestRepoMock.Verify();
            destRepoBuilder.DestRepoMock.Verify(d => d.AddAsync(It.IsAny <Destination>()), Times.Never);
            destRepoBuilder.DestRepoMock.Verify(d => d.SaveChangesAsync(), Times.Never);
        }
        public void ShouldReturnProjectStatuses()
        {
            var statuses = new List <ProjectStatus>()
            {
                new ProjectStatus()
                {
                    Id = 1, Name = "open"
                },
                new ProjectStatus()
                {
                    Id = 2, Name = "closed"
                }
            };
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper   = config.CreateMapper();
            var destRepo = new Mock <IDestinationRepository>();

            destRepo.Setup(d => d.GetProjectStatuses()).Returns(statuses.AsQueryable());
            var destServ = new DestinationService(destRepo.Object, mapper);

            var resultList = destServ.GetProjectStatuses();

            resultList.Should().NotBeNullOrEmpty();
            resultList.Should().AllBeOfType(typeof(ProjectStatusVm));
            resultList.Should().HaveCount(2);
            resultList.Should().OnlyHaveUniqueItems(ps => ps.Id);
        }
        public void ShouldReturnCountries()
        {
            var countries = new List <Country>()
            {
                new Country()
                {
                    Id = 1, Name = "country1", SubsistanceAllowenceId = 1
                },
                new Country()
                {
                    Id = 2, Name = "country2", SubsistanceAllowenceId = 1
                },
                new Country()
                {
                    Id = 3, Name = "country3", SubsistanceAllowenceId = 1
                }
            };
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper   = config.CreateMapper();
            var destRepo = new Mock <IDestinationRepository>();

            destRepo.Setup(d => d.GetAllCountries()).Returns(countries.AsQueryable());
            var destServ = new DestinationService(destRepo.Object, mapper);

            var resultList = destServ.GetCountries();

            resultList.Should().NotBeNullOrEmpty();
            resultList.Should().AllBeOfType(typeof(CountryVm));
            resultList.Should().HaveCount(3);
            resultList.Should().OnlyHaveUniqueItems(ps => ps.Id);
        }
        public void FindMyDestinations_ShouldReturn_CorrectCountOf_DestViewModels()
        {
            var user = new GoUser {
                Id = "1"
            };

            var destUserRepoBuilder = new DestinationsUsersRepositoryBuilder();
            var destUserRepo        = destUserRepoBuilder
                                      .WithAll()
                                      .Build();

            var sut = new DestinationService(null, destUserRepo, null, null, null, null, null, this.Mapper);

            var actual = sut.FindMyDestinations(user);

            var expected = new List <DestViewModel>
            {
                new DestViewModel {
                    Id = "1"
                }
            }.AsQueryable();

            Assert.Equal(expected.Count(), actual.Count());

            destUserRepoBuilder.DestUsersRepoMock.Verify();
            destUserRepoBuilder.DestUsersRepoMock.Verify(d => d.AddAsync(It.IsAny <DestinationsUsers>()), Times.Never);
            destUserRepoBuilder.DestUsersRepoMock.Verify(d => d.SaveChangesAsync(), Times.Never);
        }
        public void ShouldChangeStatusOfProject()
        {
            //arrange
            var projectShouldChange = new Project()
            {
                Id = 1, DestinationId = 1, Name = "example", ProjectStatusId = 1
            };
            var projectShouldNotChange = new Project()
            {
                Id = 2, DestinationId = 1, Name = "example2", ProjectStatusId = 2
            };
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper   = config.CreateMapper();
            var destRepo = new Mock <IDestinationRepository>();

            destRepo.Setup(d => d.GetProjectById(1)).Returns(projectShouldChange);
            destRepo.Setup(d => d.GetProjectById(2)).Returns(projectShouldNotChange);
            var destServ = new DestinationService(destRepo.Object, mapper);

            //act
            destServ.CloseProject(1);
            destServ.CloseProject(2);
            //assert
            projectShouldChange.ProjectStatusId.Should().Be(2);
            projectShouldNotChange.ProjectStatusId.Should().Be(2);
        }
        public async void Update_ErrorsOccurred_ShouldReturnErrorResponse()
        {
            var mock          = new ServiceMockFacade <IDestinationService, IDestinationRepository>();
            var model         = new ApiDestinationServerRequestModel();
            var validatorMock = new Mock <IApiDestinationServerRequestModelValidator>();

            validatorMock.Setup(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiDestinationServerRequestModel>())).Returns(Task.FromResult(new ValidationResult(new List <ValidationFailure>()
            {
                new ValidationFailure("text", "test")
            })));
            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Destination()));
            var service = new DestinationService(mock.LoggerMock.Object,
                                                 mock.MediatorMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 validatorMock.Object,
                                                 mock.DALMapperMockFactory.DALDestinationMapperMock,
                                                 mock.DALMapperMockFactory.DALPipelineStepDestinationMapperMock);

            UpdateResponse <ApiDestinationServerResponseModel> response = await service.Update(default(int), model);

            response.Should().NotBeNull();
            response.Success.Should().BeFalse();
            validatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiDestinationServerRequestModel>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <DestinationUpdatedNotification>(), It.IsAny <CancellationToken>()), Times.Never());
        }
        public async Task EditDestination_ShouldEditDestinationCorrectly()
        {
            var destRepoBuilder = new DestinationsRepositoryBuilder();
            var destRepo        = destRepoBuilder
                                  .WithAll()
                                  .Build();

            var sut = new DestinationService(destRepo, null, null, null, null, null, null, Mapper);

            var editDestinationViewModel = new EditDestinationViewModel
            {
                Id            = "2",
                Image         = SetupFileMock().Object,
                Description   = "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn",
                Level         = (LevelOfDifficulty)2,
                Naame         = "Niki",
                StartDate     = DateTime.Now.AddDays(3),
                EndDateToJoin = DateTime.Now.AddDays(1),
                EndDate       = DateTime.Now.AddDays(5)
            };


            await sut.EditDestination(editDestinationViewModel);

            var newdest = destRepo.All().FirstOrDefault(x => x.Id == "2");

            var actual = Mapper.Map <EditDestinationViewModel>(newdest);

            Assert.Equal(editDestinationViewModel, actual, new EditDestinationViewModelComparer());
        }
        public async Task AddSocialization_ShouldWorkCorrectly()
        {
            var destUsersAll = new List <DestinationsUsers>()
            {
                new DestinationsUsers()
                {
                    DestinationId = "1",
                    ParticipantId = "2"
                }
            }.AsQueryable();

            var destUsersRepoMock = new Mock <IRepository <DestinationsUsers> >();

            destUsersRepoMock.Setup(d => d.All())
            .Returns(destUsersAll).Verifiable();

            var sut = new DestinationService(null, destUsersRepoMock.Object, null, null, null, null, null, null);

            await sut.AddSocialization(new GoUser()
            {
                Id = "2"
            }, "1", "KnowSomeone");

            destUsersRepoMock.Verify();
            destUsersRepoMock.Verify(r => r.SaveChangesAsync(), Times.Once);
        }
        public void FindToDeleteDestination_ShouldThrow_WhenUserIsNotCreator()
        {
            var destAll = new List <Destination>()
            {
                new Destination()
                {
                    Id        = "1",
                    CreatorId = "1"
                }
            }.AsQueryable();

            var destRepoMock = new Mock <IRepository <Destination> >();

            destRepoMock.Setup(d => d.All())
            .Returns(destAll).Verifiable();

            var sut = new DestinationService(destRepoMock.Object, null, null, null, null, null, null, Mapper);

            var ex = Assert.Throws <ArgumentException>(() => sut.FindToDeleteDestination("1", new GoUser()
            {
                Id = "2"
            }));

            Assert.Equal("You can not delete this page", ex.Message);
        }
        public async Task AddSocialization_ShouldDoNotWorkCorrectlyIfDestinationDoNotExist()
        {
            var destUsersAll = new List <DestinationsUsers>()
            {
                new DestinationsUsers()
                {
                    DestinationId = "1",
                    ParticipantId = "2"
                }
            }.AsQueryable();

            var destUsersRepoMock = new Mock <IRepository <DestinationsUsers> >();

            destUsersRepoMock.Setup(d => d.All())
            .Returns(destUsersAll).Verifiable();

            var sut = new DestinationService(null, destUsersRepoMock.Object, null, null, null, null, null, null);

            var ex = await Assert.ThrowsAsync <ArgumentException>(async() => await sut.AddSocialization(new GoUser()
            {
                Id = "2"
            }, "5", "KnowSomeone"));

            ex.Message.ShouldBe("You are not in this group.");
            destUsersRepoMock.Verify();
        }
        public async Task AddUserToDestination_ShouldDoNotWorkCorrectlyIfDestinationDoNotExist()
        {
            var destination = new List <Destination>
            {
                new Destination
                {
                    Id = "1"
                }
            }.AsQueryable();

            var destRepoMock = new Mock <IRepository <Destination> >();

            destRepoMock.Setup(d => d.All())
            .Returns(destination).Verifiable();

            var sut = new DestinationService(destRepoMock.Object, null, null, null, null, null, null, null);

            var ex = await Assert.ThrowsAsync <ArgumentException>(async() => await sut.AddUserToDestination(new GoUser()
            {
                Id = "2"
            }, "5"));

            ex.Message.ShouldBe("Destination not exist");
            destRepoMock.Verify();
        }
 public SchedulerController()
 {
     _destService   = new DestinationService();
     _userService   = new UserService();
     _regService    = new RegistrationService();
     _actypeService = new AircraftTypeService();
     _calService    = new CalendarService();
     //_userID = Convert.ToInt32( User.Identity.GetUserId() );
 }
Beispiel #16
0
        public void CreateDestinationService_WhenParamsAreValid()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <Destination> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var destinationService = new DestinationService(mockedRepository.Object, mockedUnitOfWork.Object);

            //Act & Assert
            Assert.That(destinationService, Is.InstanceOf <DestinationService>());
        }
Beispiel #17
0
        public FrontController(DataInitializer dataInitializer)
        {
            //unitOfWork = new UnitOfWork(new ApplicationContext());

            _transportService = new TransportService(unitOfWork);

            _productService = new ProductService(unitOfWork);

            _destinationService = new DestinationService(unitOfWork);
        }
Beispiel #18
0
        public BaseController()
        {
            _packageService     = new PackageService();
            _packageTagService  = new PackageTagService();
            _destinationService = new DestinationService();
            _tagService         = new TagService();
            _vendorService      = new VendorService();
            _visaService        = new VisaService();
            _countryService     = new CountryService();

            ViewBag.Destinations = _destinationService.FilterPlacsBy_Inside_OutSIde_Bd();
        }
        public void ThrowException_WhenDestinationIsInvalid()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <Destination> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var destinationService = new DestinationService(mockedRepository.Object, mockedUnitOfWork.Object);

            Mock <Destination> destinationToAdd = null;

            //Act & Assert
            Assert.Throws <NullReferenceException>(() => destinationService.AddDestination(destinationToAdd.Object));
        }
        public async Task InitializeAsync()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            this.dbContext = new ApplicationDbContext(options);
            var unitOfWork = new UnitOfWork(this.dbContext);

            this.destinationsService = new DestinationService(unitOfWork);

            this.InitializeMapper();
        }
Beispiel #21
0
        public void ThrowException_WhenNullDestination()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <Destination> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var destinationService = new DestinationService(mockedRepository.Object, mockedUnitOfWork.Object);

            //Act
            Mock <Destination> destination = null;

            //Assert
            Assert.Throws <NullReferenceException>(() => destinationService.FindByCountry(destination.Object.Country));
        }
        public void BeCalled_WhenParamsAreValid()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <Destination> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var destinationService = new DestinationService(mockedRepository.Object, mockedUnitOfWork.Object);

            //Act
            destinationService.GetAllDestinations();

            //Assert
            mockedRepository.Verify(repository => repository.All(), Times.Once);
        }
        public TravelsController(
            TwendanisheContext context, IConfiguration configuration,
            RideService rideService, DestinationService destinationService,
            LocationService locationService
            )
        {
            _context       = context;
            _configuration = configuration;

            // Business Services
            _rideService        = rideService;
            _destinationService = destinationService;
            _locationService    = locationService;
        }
Beispiel #24
0
        public void ReturnNull_WhenNoSuchDestination()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <Destination> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var destinationService = new DestinationService(mockedRepository.Object, mockedUnitOfWork.Object);

            //Act
            mockedRepository.Setup(repository => repository.GetFirst(x => x.Country == "Bulgaria"))
            .Returns(() => null);

            //Assert
            Assert.IsNull(destinationService.FindByCountry("Bulgaria"));
        }
        public async Task AddDestination_ShouldAddTheNewDestination()
        {
            Mock <IRepository <Destination> > destinationsRepoMock = new Mock <IRepository <Destination> >();
            var fileMock = SetupFileMock();
            var sut      = new DestinationService(destinationsRepoMock.Object, null, null, null, null, null, null, Mapper);

            await sut.AddDestination(new ViewModels.CreateDestinationViewModel()
            {
                Image = fileMock.Object,
            }, new GoUser());

            destinationsRepoMock.Verify(r => r.AddAsync(It.IsAny <Destination>()), Times.Once);
            destinationsRepoMock.Verify(r => r.SaveChangesAsync(), Times.Once);
        }
        public void CallSaveChangesOnce_WhenDestinationIsValid()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <Destination> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var destinationService = new DestinationService(mockedRepository.Object, mockedUnitOfWork.Object);
            var validDestination   = new Mock <Destination>();

            //Act
            destinationService.AddDestination(validDestination.Object);

            //Assert
            mockedUnitOfWork.Verify(unit => unit.SaveChanges(), Times.Once);
        }
        public void BeInvokeOnceForTypeDestination_WhenParamsAreCorrect()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <Destination> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var destinationService = new DestinationService(mockedRepository.Object, mockedUnitOfWork.Object);
            var validDestination   = new Mock <Destination>();

            //Act
            destinationService.AddDestination(validDestination.Object);

            //Assert
            mockedRepository.Verify(repository => repository.Add(It.IsAny <Destination>()), Times.Once);
        }
        public void BeInvoked_WhenDestinationIsValid()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <Destination> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var destinationService = new DestinationService(mockedRepository.Object, mockedUnitOfWork.Object);
            var validDestination   = new Mock <Destination>();

            //Act
            destinationService.AddDestination(validDestination.Object);

            //Assert
            mockedRepository.Verify(repository => repository.Add(validDestination.Object));
        }
        public async Task AddUserToDestination_ShouldWorkCorrectlyAnd_ReturnViewModel()
        {
            var dest = new Destination
            {
                Id            = "1",
                EndDateToJoin = DateTime.Now.AddDays(3)
            };

            var destination = new List <Destination>
            {
                dest
            }.AsQueryable();

            var destRepoMock = new Mock <IRepository <Destination> >();

            destRepoMock.Setup(d => d.All())
            .Returns(destination).Verifiable();

            var user = new GoUser()
            {
                Id = "2"
            };

            var du = new DestinationsUsers {
                DestinationId = "7", ParticipantId = "5"
            };
            var destUsers = new List <DestinationsUsers> {
                du
            }.AsQueryable();

            var destUserRepoMock = new Mock <IRepository <DestinationsUsers> >();

            destUserRepoMock.Setup(d => d.All())
            .Returns(destUsers).Verifiable();

            var sut = new DestinationService(destRepoMock.Object, destUserRepoMock.Object, null, null, null, null, null, null);

            var actual = await sut.AddUserToDestination(user, "1");

            DestUserViewModel expected = new DestUserViewModel()
            {
                DestinationId = dest.Id,
                ParticipantId = user.Id
            };

            destRepoMock.Verify();

            Assert.Equal(expected, actual, new DestUserViewModelComparer());
        }
        public void ThrowException_WhenNullDestination()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <Destination> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var destinationService = new DestinationService(mockedRepository.Object, mockedUnitOfWork.Object);

            //Act
            IEnumerable <Destination> result = null;

            mockedRepository.Setup(repository => repository.All()).Returns(() => result.AsQueryable());

            //Assert
            Assert.Throws <ArgumentNullException>(() => destinationService.GetAllDestinations());
        }
Beispiel #31
0
        public void WorkerLoop()
        {
            try
            {

                // do work
                LogManager.GetLogger("SiteLogger").Info("Working on " + mWorkItem);
                //logger.logEntry(this.ToString(), "Working on " + mWorkItem, LogMsgSeverity.Information, false);

                //TODO: Write the data to the work table to support restarts
                //FileTransferService.TransferWorkDataHandler twdh = new FileTransferService.TransferWorkDataHandler();
                //FileTransferService.TransferWorkDS twDS = new FileTransferService.TransferWorkDS();
                //twDS.TransferWork.AddTransferWorkRow(0,
                //twdh.SetTransferWork(

                try
                {

                    TransferMainService transferMainService = new TransferMainService();

                    DestinationService destinationsService = new DestinationService();

                    TransferWorkService transferWorkService = new TransferWorkService();

                    FTPProcessor ifpx;
                    DoFTPActionStartDelegate dlgt;
                    IAsyncResult ar;

                    // Look up transfer record by ID
                    TransferMain tm = transferMainService.GetByTransferRefId(mWorkRefId);

                    mTransferType = (TransferTypeList)tm.TransferTypeId;

                    // check to make sure the file is complete
                    if (mTransferType == TransferTypeList.FileWatchAndProcess)
                    {
                        while (!TryToOpenInExclusiveMode(mWorkItem))
                        {
                            System.Threading.Thread.Sleep(5000);
                        }
                    }

                    // Look up transfer record by ID
                    TList<Destination> dests = destinationsService.GetByTransferRefId(mWorkRefId);

                    switch (mTransferType)
                    {
                        case TransferTypeList.FileWatchAndProcess:
                            if (tm.UsePendingFileStucture)
                                SetFilePending();

                            // Create the delegate.
                            //MDBInterfaceProcessor mdbip = new MDBInterfaceProcessor();
                            //mdbip.ProcessFileComplete += new ProcessFileCompleteDelegate(OnProcessFileComplete);

                            bool processResult;
                            ProcessTypeService pts = new ProcessTypeService();
                            ProcessType pt = pts.GetByProcessTypeId((short)tm.ProcessTypeId);

                            string path = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName;

                            this.ExecuteProcessorAssemblyMethod(mWorkItem, (short)tm.ProcessTypeId, out processResult, System.IO.Path.Combine(path, pt.LoadAssembly), pt.ClassName);
                            //mdbip.ProcessFile(mWorkItem,  (InterfaceType)ip.ProcessTypeId , out processResult);
                            break;

                        case TransferTypeList.FileWatchFtpPut:
                            if (tm.UsePendingFileStucture)
                                SetFilePending();

                            // fire a transfer for every destination you find
                            foreach (Destination dest in dests)
                            {
                                // Create the delegate.
                                ifpx = new FTPProcessor();
                                dlgt = new DoFTPActionStartDelegate(ifpx.DoFTPAction);

                                /// write transfer to work table
                                TransferWork transferWork = new TransferWork();
                                transferWork.TransferWorkRefId = Guid.NewGuid();
                                transferWork.TransferRefId = dest.TransferRefId;
                                transferWork.DestinationRefId = dest.DestinationRefId;
                                transferWork.Filename = mWorkItem;
                                transferWork.SubmitTime = DateTime.Now;
                                //transferWork.CompletionTime = DateTime.MinValue;
                                transferWork.Retires = 0;
                                transferWork.StatusTypeId = (short)StatusTypeList.New;

                                transferWorkService.Save(transferWork);

                                // Initiate the asychronous call.  Include an AsyncCallback
                                // delegate representing the callback method, and the data
                                // needed to call EndInvoke.
                                //TODO: Make this a generic call back function
                                ar = dlgt.BeginInvoke(new FTPEventArgs(dest.DestinationRefId, dest.DestServer, dest.SourceDir, dest.DestDir, dest.Username, dest.Password,
                                                        true, FtpClient.TransferType.PUT, mWorkItem, dest.DeleteAfterProcessing, ftpRetryThreshhold),
                                                        out processResult, out destinationRefId, new AsyncCallback(OnFTPActionComplete), dlgt);

                            }

                            break;

                        case TransferTypeList.FileWatchFtpPutGet:
                            break;

                        case TransferTypeList.FtpGet:
                            if (tm.UsePendingFileStucture)
                            {
                                FileInfo file = new FileInfo(mWorkItem);
                                if (!file.Exists)
                                    file.Create(); // used for gets

                                SetFilePending();
                            }

                            foreach (Destination dest in dests)
                            {
                                // Create the delegate.
                                ifpx = new FTPProcessor();
                                dlgt = new DoFTPActionStartDelegate(ifpx.DoFTPAction);

                                /// write transfer to work table
                                TransferWork transferWork = new TransferWork();
                                transferWork.TransferWorkRefId = Guid.NewGuid();
                                transferWork.TransferRefId = dest.TransferRefId;
                                transferWork.DestinationRefId = dest.DestinationRefId;
                                transferWork.Filename = mWorkItem;
                                transferWork.SubmitTime = DateTime.Now;
                                transferWork.Retires = 0;
                                transferWork.StatusTypeId = (short)StatusTypeList.New;

                                try
                                {
                                    transferWorkService.Save(transferWork);
                                }
                                catch (System.Data.SqlClient.SqlException ex)
                                {
                                    LogManager.GetLogger("SiteLogger").Warn("Error Saving Transfer work on " + mWorkItem,ex);
                                    //logger.logEntry(this.ToString(), "Error Saving Transfer work on " + mWorkItem + " " + ex.Message, LogMsgSeverity.Warning, false);
                                }

                                // Initiate the asychronous call.  Include an AsyncCallback
                                // delegate representing the callback method, and the data
                                // needed to call EndInvoke.
                                //TODO: Make this a generic call back function
                                ar = dlgt.BeginInvoke(new FTPEventArgs(dest.DestinationRefId, dest.SourceServer, dest.DestDir, dest.SourceDir, dest.Username, dest.Password,
                                                                        true, FtpClient.TransferType.GET, mWorkItem, dest.DeleteAfterProcessing,
                                                                        ftpRetryThreshhold), out processResult, out destinationRefId, new AsyncCallback(OnFTPActionComplete), dlgt);

                            }

                            break;

                        case TransferTypeList.FtpGetPut:
                            break;
                    }

                    LogManager.GetLogger("SiteLogger").Debug("Async WorkerLoop(): Started.");
                    //logger.logEntry(this.ToString(), "Async WorkerLoop(): Started.", LogMsgSeverity.Trace, false);

                    // sleep for 5 sec then check result
                    Thread.Sleep(5000);

                    LogManager.GetLogger("SiteLogger").Debug("Async WorkerLoop(): Ended.");
                    //logger.logEntry(this.ToString(), "Async WorkerLoop(): Ended.", LogMsgSeverity.Trace, false);

                }
                catch (Exception ex)
                {
                    LogManager.GetLogger("SiteLogger").Fatal("Async WorkerLoop(): Failed.", ex);
                    //logger.logEntry(this.ToString(), "Async WorkerLoop(): Failed." + ex.Message, LogMsgSeverity.Critical, false);
                }

            }
            catch (Exception ex)
            {
                LogManager.GetLogger("SiteLogger").Fatal("Async WorkerLoop(): Failed.", ex);
                //logger.logEntry(this.ToString(), "Async WorkerLoop(): Failed." + ex.Message, LogMsgSeverity.Critical, false);
            }
        }