コード例 #1
0
        private async Task <IWrappedResponse> CreateAction(MainRule rule)
        {
            var task = Task <IWrappedResponse> .Factory.StartNew(() =>
            {
                var request = rule.Context.Parent;

                var partnerDirectory = rule.Context.PartnerDirectory;

                var customerPartnerDirectoryAccess = new Olma.CustomerPartnerDirectoryAccess
                {
                    Partner     = Mapper.Map <Olma.CustomerPartner>(request),
                    DirectoryId = partnerDirectory.Id,
                    Directory   = partnerDirectory,
                };

                customerPartnerDirectoryAccess.Partner.Address = Mapper.Map <Olma.Address>(request.Address);

                _customerPartnerDirectoryAccessRepo.Create(customerPartnerDirectoryAccess);
                _customerPartnerDirectoryAccessRepo.Save();

                var responseData = Mapper.Map <Olma.CustomerPartner, CustomerPartner>(customerPartnerDirectoryAccess.Partner);
                return(Created(responseData));
            });

            return(await task);
        }
コード例 #2
0
        private Olma.CustomerPartner FindOrAddCustomerPartnerByPartner(Olma.Partner partner)
        {
            //TODO Use PartnerService to create new CustomerPartner
            var customerPartner =
                _olmaCustomerPartnerRepo.FindByCondition(cp => cp.PartnerId != null && cp.PartnerId == partner.Id).SingleOrDefault();//TODO Discuss if there are more then one CustomerPartner possible

            if (customerPartner != null)
            {
                return(customerPartner);
            }

            // if does not exist Create new customrerPartner
            customerPartner = new Olma.CustomerPartner()
            {
                Type             = partner.Type,
                CompanyName      = partner.CompanyName,
                Address          = partner.DefaultAddress,
                LoadingLocations = partner.LoadingLocations,
                PartnerId        = partner.Id,
                Partner          = partner,
                RowGuid          = Guid.NewGuid()
            };

            var directory = FindOrAddDirectoryByType(Olma.PartnerDirectoryType.ExpressCodeImportCustom, "DigitalCode Import");

            //Grant Access to Directory Entry
            var directoryAccess = new Olma.CustomerPartnerDirectoryAccess()
            {
                Partner = customerPartner
            };

            directory.CustomerPartnerDirectoryAccesses?.Add(directoryAccess);
            _olmaCustomerPartnerRepo.Create(customerPartner);
            _olmaCustomerPartnerRepo.Save();
            return(customerPartner);
        }