コード例 #1
0
ファイル: frmImport.cs プロジェクト: pwcgit/BassettForecast
 public frmImport(ImportFileType importFileType, Company company, CustomerKey customerKey)
 {
     InitializeComponent();
     this._importFileType = importFileType;
     this._company        = company;
     this._customerKey    = customerKey;
 }
コード例 #2
0
ファイル: SQLiteCommon.cs プロジェクト: cuongjpitdnu/Project
        public static List <CustomerKey> GetALlCustomerKeys()
        {
            List <CustomerKey> lstCusKeys = new List <CustomerKey>();

            try
            {
                string sql    = "SELECT * FROM CUSTOMERKEYS";
                var    result = SQLiteCommon.ExecuteSqlWithResult(sql);

                if (result != null && result.HasRows)
                {
                    while (result.Read())
                    {
                        CustomerKey cusKey = new CustomerKey();
                        cusKey.CusId      = long.Parse(result["CUSID"]?.ToString());
                        cusKey.KeyCode    = result["KEYCODE"]?.ToString();
                        cusKey.UserId     = result["USERID"]?.ToString();
                        cusKey.CreateDate = Convert.ToDateTime(result["CREATEDATE"]?.ToString());

                        lstCusKeys.Add(cusKey);
                    }
                }

                return(lstCusKeys);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        internal IResult Execute(CompanyKey brokerKey, CustomerKey customerKey)
        {
            if (brokerKey == null)
            {
                throw new ArgumentNullException("brokerKey");
            }
            if (customerKey == null)
            {
                throw new ArgumentNullException("customerKey");
            }

            var broker = _companyUnitOfWork.CompanyRepository.FindByKey(brokerKey, c => c.CompanyTypes);

            if (broker == null)
            {
                return(new InvalidResult(string.Format(UserMessages.CompanyNotFound, brokerKey.KeyValue)));
            }
            if (broker.CompanyTypes.All(t => t.CompanyTypeEnum != CompanyType.Broker))
            {
                return(new InvalidResult(string.Format(UserMessages.CompanyNotOfType, brokerKey.KeyValue, CompanyType.Broker)));
            }

            var customer = _companyUnitOfWork.CustomerRepository.FindByKey(customerKey);

            if (customer == null)
            {
                return(new InvalidResult(string.Format(UserMessages.CustomerNotFound, customerKey.KeyValue)));
            }

            customer.Broker   = broker;
            customer.BrokerId = broker.Id;

            return(new SuccessResult());
        }
コード例 #4
0
        internal IResult Execute(CustomerKey customerKey, ChileProductKey chileProductKey, string code)
        {
            var customerProductCodeKey = new CustomerProductCodeKey(customerKey, chileProductKey);
            var productCode            = _salesUnitOfWork.CustomerProductCodeRepository.FindByKey(customerProductCodeKey);

            if (productCode == null)
            {
                var customer = _salesUnitOfWork.CustomerRepository.FindByKey(customerKey);
                if (customer == null)
                {
                    return(new InvalidResult(string.Format(UserMessages.CustomerNotFound, customerKey)));
                }

                var chileProduct = _salesUnitOfWork.ChileProductRepository.FindByKey(chileProductKey);
                if (chileProduct == null)
                {
                    return(new InvalidResult(string.Format(UserMessages.ChileProductNotFound, chileProductKey)));
                }

                productCode = _salesUnitOfWork.CustomerProductCodeRepository.Add(new CustomerProductCode
                {
                    CustomerId     = customer.Id,
                    ChileProductId = chileProduct.Id
                });
            }

            productCode.Code = code;

            return(new SuccessResult());
        }
コード例 #5
0
        public async Task AddCustomerToStore(CustomerKey customerKey, CloudTable customerTable, Customer customer)
        {
            if (customerTable == null || customer == null)
            {
                throw new ArgumentNullException();
            }

            //If Key do not exists, create one. Should happens only the first time.(Found in example, need a litle more research to understand if is neccessary)
            if (customerKey == null)
            {
                customerKey = new CustomerKey
                {
                    PartitionKey = "1",
                    RowKey       = "KEY",
                    Id           = 1024
                };
                var addKey = TableOperation.Insert(customerKey);
                await customerTable.ExecuteAsync(addKey);
            }

            string code = GetCodeByKey(customerKey);

            //Update customer properties related to Key.(Found in example, need a litle more research to understand if is neccessary)
            customer.PartitionKey = $"{code[0]}";
            customer.RowKey       = code;

            //Increment and insert the Key value(Found in example, need a litle more research to understand if is neccessary)
            customerKey.Id++;
            var operation = TableOperation.Replace(customerKey);
            await customerTable.ExecuteAsync(operation);

            //Insert Customer object to Azure Storage.
            operation = TableOperation.Insert(customer);
            await customerTable.ExecuteAsync(operation);
        }
コード例 #6
0
ファイル: SQLiteCommon.cs プロジェクト: cuongjpitdnu/Project
        public static List <CustomerKey> GetALlKeysByCusId(long customerId)
        {
            List <CustomerKey> lstCusKeys = new List <CustomerKey>();

            try
            {
                string sql    = string.Format("SELECT * FROM CUSTOMERKEYS INNER JOIN KEYDEVICES ON CUSTOMERKEYS.KEYCODE = KEYDEVICES.KEYCODE WHERE CUSID= {0} ORDER BY CREATEDATE DESC", customerId);
                var    result = SQLiteCommon.ExecuteSqlWithResult(sql);

                if (result != null && result.HasRows)
                {
                    while (result.Read())
                    {
                        CustomerKey cusKey = new CustomerKey();
                        cusKey.CusId       = long.Parse(result["CUSID"]?.ToString());
                        cusKey.KeyCode     = result["KEYCODE"]?.ToString();
                        cusKey.UserId      = result["USERID"]?.ToString();
                        cusKey.MachineCode = result["MACHINECODE"]?.ToString();
                        cusKey.MacAddress  = result["MACADDRESS"]?.ToString();
                        cusKey.CreateDate  = Convert.ToDateTime(result["CREATEDATE"]?.ToString());

                        lstCusKeys.Add(cusKey);
                    }
                }

                return(lstCusKeys);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #7
0
 public frmBonusAndDiscontinuedExport(Company company, CustomerKey customerKey, ExportType exportType)
 {
     InitializeComponent();
     this._company     = company;
     this._customerKey = customerKey;
     this._exportType  = exportType;
 }
コード例 #8
0
ファイル: SQLiteCommon.cs プロジェクト: cuongjpitdnu/Project
        public static CustomerKey GetCustomerKeyByKeyCode(string keyCode)
        {
            CustomerKey   cusKey   = new CustomerKey();
            List <string> listMacs = new List <string>();

            listMacs.AddRange(new string[] { "", "", "", "", "" });

            try
            {
                string sql    = string.Format("SELECT * FROM KEYDEVICES WHERE KEYCODE='{0}'", keyCode);
                var    result = SQLiteCommon.ExecuteSqlWithResult(sql);

                if (result != null && result.HasRows)
                {
                    int i = 0;
                    while (result.Read())
                    {
                        cusKey.MachineCode = result["MACHINECODE"]?.ToString();
                        cusKey.KeyCode     = result["KEYCODE"]?.ToString();
                        var macAddress = result["MACADDRESS"]?.ToString();
                        listMacs[i] = macAddress;
                        i++;
                    }
                }

                cusKey.ListMacAddress = listMacs;

                return(cusKey);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #9
0
        private PurchaseErrorCode ValidatePurchaseRequest(CustomerKey customerKey, Money totalCost)
        {
            VirtualAccount account = _virtualAccountServiceGateway.GetAccount(customerKey);

            if (account.Balance.AvailableAmount < totalCost)
            {
                return(PurchaseErrorCode.NotEnoughFunds);
            }

            BetLimitStatusAfterBet betPeriodSummary = _bettingServiceGateway.GetBetLimitStatusForAmount(customerKey, totalCost);

            if (betPeriodSummary.AffectedLimit == BetLimit.LimitNotSet)
            {
                return(PurchaseErrorCode.LimitNotSet);
            }

            if (betPeriodSummary.Exceeded)
            {
                switch (betPeriodSummary.AffectedLimit)
                {
                case BetLimit.Daily:
                    return(PurchaseErrorCode.ExceededDailyBetLimit);

                case BetLimit.Weekly:
                    return(PurchaseErrorCode.ExceededWeeklyBetLimit);

                case BetLimit.Monthly:
                    return(PurchaseErrorCode.ExceededMonthlyBetLimit);

                default:
                    return(PurchaseErrorCode.ExceededDailyBetLimit);
                }
            }
            return(PurchaseErrorCode.NotSet);
        }
コード例 #10
0
 private void frmForecastExport_Load(object sender, EventArgs e)
 {
     try
     {
         cboCustomer.ValueMember   = "Code";
         cboCustomer.DisplayMember = "CodeDescription";
         txtFilePath.Text          = ConfigurationManager.AppSettings["ExportSalesRateFilePath"];
         if (_company != null)
         {
             txtCompanyCode.Text = _company.CompanyCode.ToString();
             txtCompanyName.Text = _company.CompanyName.ToString();
             CustomerKey saveCustomerKey = _customerKey;
             cboCustomer.DataSource = Utility.GetInstance().GetCustomerDropDownCollection(_company, "default");
             _customerKey           = saveCustomerKey;
             if (_customerKey != null)
             {
                 for (int index = 1; index < cboCustomer.Items.Count; index++)
                 {
                     if (((DropDownItem)cboCustomer.Items[index]).Code == _customerKey.CustomerNumber)
                     {
                         cboCustomer.SelectedIndex = index;
                         break;
                     }
                 }
                 bindingSourceSavedSalesRate.DataSource = PWC.PersistenceLayer.Utility.GetInstance().GetSavedSalesRateDateCollection(_customerKey.CompanyCode.Value, _customerKey.CustomerNumber.Value, 12);
             }
         }
     }
     catch (Exception ex)
     {
         Utility.GetInstance().HandleException(this, ex, e);
     }
 }
コード例 #11
0
        private void Serialize(ChileProductKey chileProductKey, CustomerKey customerKey, out int prodId, out string companyIA)
        {
            var chileProduct = UnitOfWork.ChileProductRepository.FindByKey(chileProductKey, c => c.Product);
            var customer     = UnitOfWork.CustomerRepository.FindByKey(customerKey,
                                                                       c => c.Company,
                                                                       c => c.ProductSpecs);

            var pId      = prodId = int.Parse(chileProduct.Product.ProductCode);
            var cIA      = companyIA = customer.Company.Name;
            var existing = OldContext.SerializedCustomerProdSpecs.FirstOrDefault(s => s.ProdID == pId && s.Company_IA == cIA);

            var specs = customer.ProductSpecs.Where(s => s.ChileProductId == chileProduct.Id).ToList();

            if (!specs.Any())
            {
                if (existing != null)
                {
                    OldContext.SerializedCustomerProdSpecs.DeleteObject(existing);
                }
            }
            else
            {
                if (existing == null)
                {
                    existing = new SerializedCustomerProdSpecs
                    {
                        ProdID     = prodId,
                        Company_IA = companyIA
                    };
                    OldContext.SerializedCustomerProdSpecs.AddObject(existing);
                }

                existing.Serialized = SerializableCustomerSpec.Serialize(specs);
            }
        }
コード例 #12
0
        internal IResult <CustomerProductCodeReturn> Execute(CustomerKey customerKey, ChileProductKey chileProductKey)
        {
            var predicate = new CustomerProductCodeKey(customerKey, chileProductKey).FindByPredicate;
            var select    = CustomerProductCodeProjectors.Select();
            var code      = _salesUnitOfWork.CustomerProductCodeRepository.Filter(predicate).Select(select).FirstOrDefault();

            return(new SuccessResult <CustomerProductCodeReturn>(code));
        }
コード例 #13
0
        internal static IResult <CreatePackScheduleCommandParameters> ToParsedParameters(this ICreatePackScheduleParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var workTypeKey = KeyParserHelper.ParseResult <IWorkTypeKey>(parameters.WorkTypeKey);

            if (!workTypeKey.Success)
            {
                return(workTypeKey.ConvertTo((CreatePackScheduleCommandParameters)null));
            }

            var chileProductKey = KeyParserHelper.ParseResult <IChileProductKey>(parameters.ChileProductKey);

            if (!chileProductKey.Success)
            {
                return(chileProductKey.ConvertTo((CreatePackScheduleCommandParameters)null));
            }

            var packagingProductKey = KeyParserHelper.ParseResult <IPackagingProductKey>(parameters.PackagingProductKey);

            if (!packagingProductKey.Success)
            {
                return(packagingProductKey.ConvertTo((CreatePackScheduleCommandParameters)null));
            }

            var productionLocationKey = KeyParserHelper.ParseResult <ILocationKey>(parameters.ProductionLineKey);

            if (!productionLocationKey.Success)
            {
                return(productionLocationKey.ConvertTo((CreatePackScheduleCommandParameters)null));
            }

            CustomerKey customerKey = null;

            if (!string.IsNullOrWhiteSpace(parameters.CustomerKey))
            {
                var customerKeyResult = KeyParserHelper.ParseResult <ICustomerKey>(parameters.CustomerKey);
                if (!customerKeyResult.Success)
                {
                    return(productionLocationKey.ConvertTo((CreatePackScheduleCommandParameters)null));
                }
                customerKey = new CustomerKey(customerKeyResult.ResultingObject);
            }

            return(new SuccessResult <CreatePackScheduleCommandParameters>(new CreatePackScheduleCommandParameters
            {
                Parameters = parameters,

                WorkTypeKey = new WorkTypeKey(workTypeKey.ResultingObject),
                ChileProductKey = new ChileProductKey(chileProductKey.ResultingObject),
                PackagingProductKey = new PackagingProductKey(packagingProductKey.ResultingObject),
                ProductionLocationKey = new LocationKey(productionLocationKey.ResultingObject),
                CustomerKey = customerKey
            }));
        }
コード例 #14
0
 private CustomerBettingReferenceInfo GetCustomerBettingInfo(CustomerKey customerKey)
 {
     return(new CustomerBettingReferenceInfo
     {
         CustomerKey = customerKey,
         BettingCardType = BettingCardType.EtotoCard,
         ExternalAccountKey = _customerServiceGateway.GetAccountNumber(customerKey)
     });
 }
コード例 #15
0
        private void dgvCusKeys_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            var cusSelected = (MCustomer)dgvCustomerList.CurrentRow.DataBoundItem;

            CreateKeyForm createKeyForm = new CreateKeyForm();

            createKeyForm.Mode            = CreateKeyForm.ViewMode.EDIT;
            createKeyForm.currentCustomer = cusSelected;
            CustomerKey   cusKey    = null;
            List <string> lstOldMac = new List <string>();

            try
            {
                var x = SQLiteCommon.GetALlKeyDevices();

                cusKey = (CustomerKey)dgvCusKeys.CurrentRow.DataBoundItem;
                if (cusKey == null)
                {
                    return;
                }

                lstOldMac = SQLiteCommon.GetCustomerKeyByKeyCode(cusKey.KeyCode).ListMacAddress;
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ShowMsg(MessageBoxIcon.Error, ex.Message);
            }

            Params param = new Params
            {
                KeyCode     = cusKey.KeyCode,
                MachineCode = cusKey.MachineCode,
                ListMacs    = lstOldMac
            };

            createKeyForm.param = param;
            createKeyForm.InitForm();
            DialogResult result = createKeyForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (createKeyForm.isSuccess)
                {
                    loadCustomerKey();
                }
            }
        }
コード例 #16
0
        public void Setup()
        {
            try
            {
                var customer = Gateway.Customer.Find(CustomerKey.ToString());

                Gateway.Customer.Delete(CustomerKey.ToString());
            }
            catch (Exception)
            {
                // skip it
            }
        }
コード例 #17
0
        private void frmForecastVarianceReport_Load(object sender, EventArgs e)
        {
            try
            {
                cboCustomerFrom.ValueMember          = "Code";
                cboCustomerFrom.DisplayMember        = "CodeDescription";
                cboBrandFrom.ValueMember             = "Code";
                cboBrandFrom.DisplayMember           = "CodeDescription";
                cboBrandFrom.DataSource              = Utility.GetInstance().GetBrandDropDownCollection();
                cboProductCategoryFrom.ValueMember   = "Code";
                cboProductCategoryFrom.DisplayMember = "CodeDescription";
                cboProductCategoryFrom.DataSource    = Utility.GetInstance().GetProductCategoryDropDownCollection();
                cboCustomerTo.ValueMember            = "Code";
                cboCustomerTo.DisplayMember          = "CodeDescription";
                cboBrandTo.ValueMember             = "Code";
                cboBrandTo.DisplayMember           = "CodeDescription";
                cboBrandTo.DataSource              = Utility.GetInstance().GetBrandDropDownCollection();
                cboProductCategoryTo.ValueMember   = "Code";
                cboProductCategoryTo.DisplayMember = "CodeDescription";
                cboProductCategoryTo.DataSource    = Utility.GetInstance().GetProductCategoryDropDownCollection();

                txtForecastYear.Text = DateTime.Today.Year.ToString("0000");
                txtFilePath.Text     = ConfigurationManager.AppSettings["ReportForecastFilePath"];
                if (_company != null)
                {
                    txtCompanyCode.Text = _company.CompanyCode.ToString();
                    txtCompanyName.Text = _company.CompanyName.ToString();
                    CustomerKey saveCustomerKey = _customerKey;
                    cboCustomerFrom.DataSource = Utility.GetInstance().GetCustomerDropDownCollection(_company, "CustomerNumber");
                    cboCustomerTo.DataSource   = Utility.GetInstance().GetCustomerDropDownCollection(_company, "CustomerNumber");
                    _customerKey = saveCustomerKey;
                    if (_customerKey != null)
                    {
                        for (int index = 1; index < cboCustomerFrom.Items.Count; index++)
                        {
                            if (((DropDownItem)cboCustomerFrom.Items[index]).Code == _customerKey.CustomerNumber)
                            {
                                cboCustomerFrom.SelectedIndex = index;
                                cboCustomerTo.SelectedIndex   = index;
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.GetInstance().HandleException(this, ex, e);
            }
        }
コード例 #18
0
        public void GetCustomerWhenExistReturnCustomer()
        {
            Customer    customer = customers[0];
            CustomerKey key      = new CustomerKey()
            {
                Id = customer.CustomerId, Name = customer.Name
            };

            mockCustomerRepository.Setup(m => m.FindById(key.Id, key.Name)).Returns(customer);

            Customer result = customerService.Get(key);

            Assert.That(result, Is.EqualTo(customer));
        }
コード例 #19
0
        public void DeleteCustomerWhenExistReturnNoExceptionDeleteLinkedAddresses()
        {
            //SETUP
            var addresses = new List <Address>
            {
                new Address {
                    CustomerId = "1", AddressTypeId = 1, Name = "Alex", Street = "Zielona", ZIP = "24605", City = "Wroclaw", CountryId = 171
                },
                new Address {
                    CustomerId = "1", AddressTypeId = 2, Name = "Alex", Street = "Czerwona", ZIP = "24601", City = "Wroclaw", CountryId = 171
                },
                new Address {
                    CustomerId = "3", AddressTypeId = 3, Name = "Ola", Street = "Pomaranczowa", ZIP = "24605", City = "Wroclaw", CountryId = 171
                },
                new Address {
                    CustomerId = "2", AddressTypeId = 2, Name = "Alex", Street = "Szara", ZIP = "24601", City = "Wroclaw", CountryId = 171
                }
            };

            Mock <IAddressRepository> mockAddressRepository = new Mock <IAddressRepository>();

            mockAddressRepository.Setup(m => m.GetAll()).Returns(addresses);

            //IQueryable myFilteredFoos = null;
            //Address addressKeyForDelete = new Ad
            //mockAddressRepository.Setup(r => r.Delete(It.IsAny<Address>()))
            //     .Callback((Address address) =>        myFilteredFoos = addresses.Where())
            //        .Returns(() => myFilteredFoos.Cast<IFooBar>());

            mockUniOfWork.Setup(m => m.Addresses).Returns(mockAddressRepository.Object);

            customerService = new CustomerService(mockUniOfWork.Object);
            var addressService = new AddressService(mockUniOfWork.Object);

            var customerKey = new CustomerKey()
            {
                Id = "1", Name = "Alex"
            };

            //ACT
            customerService.Delete(customerKey);

            //ASSERT
            var resultCustomer = customerService.Get(customerKey);
            var resultAddress  = addressService.GetAll().Where(a => a.CustomerId == customerKey.Id);

            Assert.That(resultCustomer, Is.EqualTo(null));
            // mockAddressRepository.Verify(r => r.Delete(It.IsAny<Address>()));
        }
コード例 #20
0
        public IHttpActionResult GetNumberOfActiveGames()
        {
            CustomerKey customerKey = _customerProvider.FindCurrentCustomerKey();
            var         betDate     = _betDateProvider.Today;

            var deliveredTicketsCount = _bettingHistoryServiceGateway.GetNumberOfDeliveredTickets(customerKey, betDate);

            var expertOrdersCount = _expertMarketServiceGateway.GetNumberOfNotDeliveredShareOrders(customerKey, betDate);

            var teamGameOrdersCount = _teamGameServiceGateway.GetNumberOfNotDeliveredShareOrders(customerKey, betDate);

            var numberOfActiveGames = deliveredTicketsCount + expertOrdersCount + teamGameOrdersCount;

            return(Ok(RestResult <int> .CreateSuccess(numberOfActiveGames)));
        }
コード例 #21
0
        public IHttpActionResult GetCredit()
        {
            CustomerKey customerKey = _customerProvider.FindCurrentCustomerKey();

            BetLimitStatusAfterBet betLimitStatus = _bettingServiceGateway.GetBetLimitStatusForAmount(customerKey, Money.FromKroner(0));
            VirtualAccount         account        = _virtualAccountServiceGateway.GetAccount(customerKey);

            var model = new Credit
            {
                Balance           = account.Balance.AvailableAmount.Amount,
                RemainingBetLimit = betLimitStatus.LowestLimitRemainder.Amount,
                HasBetLimit       = betLimitStatus.AffectedLimit != BetLimit.LimitNotSet
            };

            return(Ok(RestResult <Credit> .CreateSuccess(model)));
        }
コード例 #22
0
        /// <summary>
        /// Get the code generated for the provided key.
        /// </summary>
        /// <param name="customerKey"></param>
        /// <returns></returns>
        private string GetCodeByKey(CustomerKey customerKey)
        {
            //(Found in example, need a litle more research to understand if is neccessary)

            int          idx      = customerKey.Id;
            const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            var          s        = string.Empty;

            while (idx > 0)
            {
                s   += ALPHABET[idx % ALPHABET.Length];
                idx /= ALPHABET.Length;
            }
            var code = string.Join(string.Empty, s.Reverse());

            return(code);
        }
コード例 #23
0
        internal IResult Execute(CompanyKey brokerKey, CustomerKey customerKey)
        {
            if (brokerKey == null)
            {
                throw new ArgumentNullException("brokerKey");
            }
            if (customerKey == null)
            {
                throw new ArgumentNullException("customerKey");
            }

            var broker = _companyUnitOfWork.CompanyRepository.FindByKey(brokerKey, c => c.CompanyTypes);

            if (broker == null)
            {
                return(new InvalidResult(string.Format(UserMessages.CompanyNotFound, brokerKey.KeyValue)));
            }
            if (broker.CompanyTypes.All(t => t.CompanyTypeEnum != CompanyType.Broker))
            {
                return(new InvalidResult(string.Format(UserMessages.CompanyNotOfType, brokerKey.KeyValue, CompanyType.Broker)));
            }

            var customer = _companyUnitOfWork.CustomerRepository.FindByKey(customerKey, c => c.Broker);

            if (customer == null)
            {
                return(new InvalidResult(string.Format(UserMessages.CustomerNotFound, customerKey.KeyValue)));
            }

            if (!brokerKey.Equals(new CompanyKey(customer.Broker)))
            {
                return(new InvalidResult(string.Format(UserMessages.CustomerNotOfBroker, customerKey.KeyValue, brokerKey.KeyValue)));
            }

            var rvcBroker = _companyUnitOfWork.CompanyRepository.Filter(c => c.Name == Data.Models.StaticRecords.StaticCompanies.RVCBroker.Name).FirstOrDefault();

            if (rvcBroker == null)
            {
                throw new Exception("Default RVC Broker Company not found.");
            }

            customer.Broker   = rvcBroker;
            customer.BrokerId = rvcBroker.Id;

            return(new SuccessResult());
        }
コード例 #24
0
        public IHttpActionResult ProcessPurchase(PurchaseRequest purchase)
        {
            BetData betData = BetData.Parse(purchase.BetData);

            CustomerKey customerKey = _customerProvider.GetCurrentCustomer().Key;

            PurchaseErrorCode errorCode = ValidatePurchaseRequest(customerKey, betData.EstimatedTotalPrice);

            if (errorCode != PurchaseErrorCode.NotSet)
            {
                return(Ok(RestResult <string> .CreateFailed(errorCode.ToString())));
            }

            Guid purchaseIdentifier = Guid.NewGuid();

            CommandResult placeBetResult = _bettingServiceGateway.Execute(new PlaceNormalBetForMultiLegGame
            {
                PurchaseIdentifier  = purchaseIdentifier,
                CustomerPlacingBet  = _customerServiceGateway.GetBettingReference(GetCustomerBettingInfo(customerKey)),
                RaceDay             = betData.RaceDayKey,
                Product             = betData.BetTypeCode,
                FirstRaceNumber     = betData.RaceNumber,
                IsFirstPrizeOnlyBet = betData.IsFirstPrizeOnlyBet,
                LegMarks            = betData.Marks.ToDictionary(mark => mark.LegNumber, mark => mark.Marks),
                RowPrice            = Money.FromOere(betData.RowPrice)
            });

            if (!placeBetResult.IsExecuted)
            {
                return(Ok(RestResult <string> .CreateFailed(placeBetResult.ErrorCode.ToString(), placeBetResult.Message)));
            }

            TicketKey ticketKey = _bettingServiceGateway.GetTicketSerialNumber(purchaseIdentifier);

            SingleBetItem betItem = _bettingHistoryServiceGateway.GetBetItem(new TicketKey(ticketKey.TicketSerialNumber));

            return(Ok(RestResult <PurchaseReceipt> .CreateSuccess(new PurchaseReceipt
            {
                TicketSerialNumber = ticketKey.TicketSerialNumber,
                RaceDay = RaceDayKey.ToString(betData.RaceDayKey),
                Product = betData.BetTypeCode.ToString(),
                SellFee = betItem.TicketReceipt.SellFee.Amount,
                BetCost = betItem.TicketReceipt.BetCost.Amount,
                PurchaseTime = betItem.TicketReceipt.BetTimeSold
            })));
        }
コード例 #25
0
        public static async Task RunExtractor([Table("customers")] CloudTable customerTable,
                                              [Table("customers", "1", "KEY", Take = 1)] CustomerKey customerKey,
                                              [QueueTrigger("customersQueue")] Customer customer, TraceWriter log)
        {
            try
            {
                ICustomerService customerService = new AzureCustomerService();

                await customerService.AddCustomerToStore(customerKey, customerTable, customer);
            }
            catch (Exception ex)
            {
                log.Info($"HTTP trigger function 'Extractor' fail to processed a request, with the message: '{ex.Message}'.");

                throw;
            }
        }
コード例 #26
0
ファイル: frmImport.cs プロジェクト: pwcgit/BassettForecast
 private void cboCustomer_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (cboCustomer.SelectedIndex < 0)
         {
             return;
         }
         string customerNumber = ((DropDownItem)cboCustomer.SelectedItem).Code;
         if (customerNumber == string.Empty)
         {
             _customerKey = null;
             return;
         }
         _customerKey = new CustomerKey(txtCompanyCode.Text, customerNumber);
     }
     catch (Exception ex)
     {
         Utility.GetInstance().HandleException(this, ex, e);
     }
 }
コード例 #27
0
        public void Can_Create_A_Customer()
        {
            //// Arrange
            var gateway = BraintreeProviderSettings.AsBraintreeGateway();

            var customerRequest = new CustomerRequest()
            {
                CustomerId = CustomerKey.ToString(),
                FirstName  = "Rusty",
                LastName   = "Swayne",
                Company    = "Mindfly",
                Email      = "*****@*****.**",
                Website    = "http://www.mindfly.com"
            };

            //// Act
            var result = gateway.Customer.Create(customerRequest);

            //// Assert
            Assert.IsTrue(result.IsSuccess());
        }
コード例 #28
0
 private void cboCustomer_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (cboCustomer.SelectedIndex < 0)
         {
             return;
         }
         string customerNumber = ((DropDownItem)cboCustomer.SelectedItem).Code;
         if (customerNumber == string.Empty)
         {
             _customerKey = null;
             return;
         }
         _customerKey = new CustomerKey(txtCompanyCode.Text, customerNumber);
         bindingSourceSavedSalesRate.DataSource = PWC.PersistenceLayer.Utility.GetInstance().GetSavedSalesRateDateCollection(txtCompanyCode.Text, customerNumber, 12);
     }
     catch (Exception ex)
     {
         Utility.GetInstance().HandleException(this, ex, e);
     }
 }
コード例 #29
0
        private void CreateReceivablesCreditMemo(int KeyCompany, DataTable tblVenta, string sCultureName, int RecordPos, string sChequera)
        {
            Context Context = new Context();

            Context.OrganizationKey = (OrganizationKey) new CompanyKey()
            {
                Id = KeyCompany
            };
            Context.CultureName = sCultureName;
            ReceivablesDocumentKey receivablesDocumentKey = new ReceivablesDocumentKey();
            CustomerKey            customerKey            = new CustomerKey();

            customerKey.Id = Convert.ToString(tblVenta.Rows[RecordPos]["idCliente"]);
            BatchKey batchKey = new BatchKey();

            batchKey.Id = tblVenta.Rows[RecordPos]["IDLote"].ToString();
            MoneyAmount moneyAmount = new MoneyAmount();

            moneyAmount.Currency = Convert.ToString(tblVenta.Rows[RecordPos]["IDMoneda"]);
            moneyAmount.Value    = Convert.ToDecimal(tblVenta.Rows[RecordPos]["MontoXCobrar"]);
            ReceivablesCreditMemo receivablesCreditMemo = new ReceivablesCreditMemo();
            string str = tblVenta.Rows[RecordPos]["NoDocumento"].ToString();

            receivablesDocumentKey.Id = str;
            receivablesCreditMemo.Key = receivablesDocumentKey;
            if (tblVenta.Rows[RecordPos]["Fecha"].ToString() != "")
            {
                receivablesCreditMemo.Date = new DateTime?(Convert.ToDateTime(tblVenta.Rows[RecordPos]["Fecha"]));
            }
            receivablesCreditMemo.BatchKey    = batchKey;
            receivablesCreditMemo.CustomerKey = customerKey;
            receivablesCreditMemo.SalesAmount = moneyAmount;
            Policy policyByOperation = this.wsDynamicsGP.GetPolicyByOperation("CreateReceivablesCreditMemo", Context);

            this.wsDynamicsGP.CreateReceivablesCreditMemo(receivablesCreditMemo, Context, policyByOperation);
        }
コード例 #30
0
        public static Expression <Func <SampleOrder, bool> > ByRequestCustomer(CustomerKey requestedCustomerKey)
        {
            var customerPredicate = requestedCustomerKey.FindByPredicate;

            return(o => new[] { o.RequestCustomer }.Where(c => c != null).Any(c => customerPredicate.Invoke(c)));
        }