/// <summary>
        /// konstruktor regisztrációs adatokkal  
        /// </summary>
        /// <param name="registration"></param>
        public RegistrationFileRepository(CompanyGroup.Domain.RegistrationModule.Registration registration)
        {
            Helpers.DesignByContract.Require((registration != null), "Registration data cannot be null or empty!");

            this.registration = registration;
        }
        /// <summary>
        /// új regisztráció hozzáadása 
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public CompanyGroup.Dto.RegistrationModule.Registration AddNew(CompanyGroup.Dto.ServiceRequest.AddNewRegistration request)
        {
            try
            {
                CompanyGroup.Helpers.DesignByContract.Require((request != null), "Registration datarecording cannot be null!");

                CompanyGroup.Domain.RegistrationModule.Registration registration = null;

                //be kell-e tölteni a UI-on az adatokat?
                bool loadData = false;

                //bejelentkezett felhasználó lekérdezése
                CompanyGroup.Domain.PartnerModule.Visitor visitor = base.GetVisitor(request.VisitorId);

                //ha be van jelentkezve a felhasználó, akkor le kell kérdezni a korábbi regisztrációs adatokat
                if (visitor.IsValidLogin && (String.IsNullOrEmpty(request.RegistrationId) || MongoDB.Bson.ObjectId.Empty.ToString().Equals(request.RegistrationId)))
                {
                    registration = new CompanyGroup.Domain.RegistrationModule.Registration();

                    registration.DataRecording = new Domain.RegistrationModule.DataRecording();

                    List<CompanyGroup.Domain.PartnerModule.BankAccount> bankAccounts = customerRepository.GetBankAccounts(visitor.CustomerId, CompanyGroup.Domain.Core.Constants.DataAreaIdHrp);

                    List<CompanyGroup.Domain.PartnerModule.ContactPerson> contactPersons = customerRepository.GetContactPersons(visitor.CustomerId, CompanyGroup.Domain.Core.Constants.DataAreaIdHrp);

                    CompanyGroup.Domain.PartnerModule.Customer customer = customerRepository.GetCustomer(visitor.CustomerId, CompanyGroup.Domain.Core.Constants.DataAreaIdHrp);

                    List<CompanyGroup.Domain.PartnerModule.DeliveryAddress> deliveryAddresses = customerRepository.GetDeliveryAddress(visitor.CustomerId, CompanyGroup.Domain.Core.Constants.DataAreaIdHrp);

                    CompanyGroup.Domain.PartnerModule.MailAddress mailAddress = customerRepository.GetMailAddress(visitor.CustomerId, CompanyGroup.Domain.Core.Constants.DataAreaIdHrp);

                    //registration.BankAccountList = new List<Domain.RegistrationModule.BankAccount>();

                    registration.BankAccountList = bankAccounts.ConvertAll<CompanyGroup.Domain.RegistrationModule.BankAccount>(x => { return new CompanyGroup.Domain.RegistrationModule.BankAccount(x.Number, x.RecId); });

                    registration.ContactPersonList = contactPersons.FindAll(x => x.WebAdmin == false).ConvertAll<CompanyGroup.Domain.RegistrationModule.ContactPerson>(x => { 
                        
                        return new CompanyGroup.Domain.RegistrationModule.ContactPerson(x.ContactPersonId, 
                                                                                        x.LastName, 
                                                                                        x.FirstName, 
                                                                                        x.Email, 
                                                                                        x.Telephone, 
                                                                                        x.Telephone, 
                                                                                        x.AllowOrder, 
                                                                                        x.AllowReceiptOfGoods, 
                                                                                        x.SmsArriveOfGoods, 
                                                                                        x.SmsOrderConfirm, 
                                                                                        x.SmsOfDelivery, 
                                                                                        x.EmailArriveOfGoods, 
                                                                                        x.EmailOfOrderConfirm, 
                                                                                        x.EmailOfDelivery, 
                                                                                        x.WebAdmin, 
                                                                                        x.PriceListDownload, 
                                                                                        x.InvoiceInfo, 
                                                                                        x.UserName, 
                                                                                        x.Password, 
                                                                                        x.LeftCompany,
                                                                                        x.Newsletter,
                                                                                        x.RecId, 
                                                                                        x.RefRecId, 
                                                                                        x.Positions); 
                    });

                    registration.CompanyData = new Domain.RegistrationModule.CompanyData(customer.InvoiceCountry, customer.CustomerId, customer.CustomerName, customer.EUVatNumber, customer.Email, 
                                                                                         customer.Newsletter, customer.CompanyRegisterNumber, customer.SignatureEntityFile, customer.VatNumber);

                    registration.CompanyId = customer.CustomerId;

                    registration.DeliveryAddressList = deliveryAddresses.ConvertAll<CompanyGroup.Domain.RegistrationModule.DeliveryAddress>(x => { 
                        
                        return new CompanyGroup.Domain.RegistrationModule.DeliveryAddress(x.RecId, x.City, x.ZipCode, x.Street, x.CountryRegionId); 
                    
                    });

                    registration.MailAddress = new Domain.RegistrationModule.MailAddress(customer.MailCity, customer.MailCountry, customer.MailZipCode, customer.MailStreet);

                    registration.InvoiceAddress = new Domain.RegistrationModule.InvoiceAddress(customer.InvoiceCity, customer.InvoiceCountry, customer.InvoiceZipCode, customer.InvoiceStreet, customer.InvoicePhone);


                    CompanyGroup.Domain.PartnerModule.ContactPerson webAdmin = contactPersons.FirstOrDefault(x => x.WebAdmin == true);

                    

                    registration.WebAdministrator = (webAdmin == null) ? new CompanyGroup.Domain.RegistrationModule.WebAdministrator() :
                        
                                                                         new CompanyGroup.Domain.RegistrationModule.WebAdministrator(webAdmin.ContactPersonId,
                                                                                                                webAdmin.LastName,
                                                                                                                webAdmin.FirstName,
                                                                                                                webAdmin.Email,
                                                                                                                webAdmin.Telephone,
                                                                                                                webAdmin.Telephone,
                                                                                                                webAdmin.AllowOrder,
                                                                                                                webAdmin.AllowReceiptOfGoods,
                                                                                                                webAdmin.SmsArriveOfGoods,
                                                                                                                webAdmin.SmsOrderConfirm,
                                                                                                                webAdmin.SmsOfDelivery,
                                                                                                                webAdmin.EmailArriveOfGoods,
                                                                                                                webAdmin.EmailOfOrderConfirm,
                                                                                                                webAdmin.EmailOfDelivery, 
                                                                                                                webAdmin.PriceListDownload,
                                                                                                                webAdmin.InvoiceInfo,
                                                                                                                webAdmin.UserName,
                                                                                                                webAdmin.Password,
                                                                                                                webAdmin.LeftCompany,
                                                                                                                webAdmin.Newsletter,
                                                                                                                webAdmin.RecId,
                                                                                                                webAdmin.RefRecId, 
                                                                                                                webAdmin.Positions);
                    
                    registration.VisitorId = visitor.VisitorId;

                    registration.Status = Domain.RegistrationModule.RegistrationStatus.Created;

                    loadData = true;
                }

                //ha nem üres a kérésben szereplő regisztrációs azonosító, akkor annak lekérdezése történik a cacheDb-ből
                if (!String.IsNullOrEmpty(request.RegistrationId) && !MongoDB.Bson.ObjectId.Empty.ToString().Equals(request.RegistrationId))
                {
                    registration = registrationRepository.GetByKey(request.RegistrationId);
                }

                //ha nincs megkezdett regisztráció 
                if (registration == null || MongoDB.Bson.ObjectId.Empty.Equals(registration.Id))
                {
                    //üres regisztráció létrehozása
                    CompanyGroup.Domain.RegistrationModule.Registration newRegistration = (registration == null) ? CompanyGroup.Domain.RegistrationModule.Factory.CreateRegistration() : registration;

                    //új regisztrációs azonosító létrehozása
                    newRegistration.Id = MongoDB.Bson.ObjectId.GenerateNewId();

                    newRegistration.CompanyId = visitor.IsValidLogin ? visitor.CustomerId : String.Empty;

                    newRegistration.PersonId = visitor.IsValidLogin ? visitor.PersonId : String.Empty;

                    newRegistration.VisitorId = visitor.IsValidLogin ? request.VisitorId : String.Empty;

                    //új regisztráció mentés 
                    registrationRepository.Add(newRegistration);

                    //új regisztráció visszaolvasás
                    registration = registrationRepository.GetByKey(newRegistration.Id.ToString());

                    loadData = true;
                }

                //ha még mindíg nincs meg a regisztráció, akkor egy új létrehozása szükséges
                if (registration == null)
                {
                    registration = CompanyGroup.Domain.RegistrationModule.Factory.CreateRegistration();

                    loadData = true;
                }

                //bankszámlaszámok szétdarabolása
                registration.BankAccountList.ForEach(x => x.SplitBankAccount());

                CompanyGroup.Dto.RegistrationModule.Registration response = new RegistrationToRegistration().MapDomainToDto(registration);

                response.Visitor = new CompanyGroup.ApplicationServices.PartnerModule.VisitorToVisitor().Map(visitor);

                response.LoadData = loadData;

                return response;
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }