public void Get_test()
        {
            // arrange
            var maker = "Intel";
            var processorSpeed = 500;
            var ramSize = 2000;
            processors[0] = new Dictionary<string, object>
            {
                { "Maker", maker},
                { "Speed", processorSpeed},
                { "RamId", 0 }
            };
            rams[0] = new Dictionary<string, object>
            {
                { "Size", ramSize }
            };
            var aggregatorProvider = aggregatorProviderMock.Object;
            var processorModel = new ProcessorModel(0, processorCollectionMock.Object);
            var ramModel = new RAMModel(0, ramCollectionMock.Object);
            var computer = new Computer(aggregatorProvider, processorModel);
            var ram = new RAM(aggregatorProvider, ramModel);
            aggregatorProvider.Save(computer, ram);

            // act and assert
            computer.RAM.Size.Should().Be(ramSize);
            computer.ProcessorSpeed.Should().Be(processorSpeed);
            computer.Maker.Should().Be(maker);
        }
Exemple #2
0
 public Processor(ProcessorModel model)
 {
     this.model        = model;
     requireComponents = new List <Type>()
     {
         typeof(MotherBoard)
     };
 }
Exemple #3
0
        public IBaseEntity ToEntity(BaseModel powerSupply)
        {
            ProcessorModel processorModel = (ProcessorModel)powerSupply;

            return(new ProcessorEntity
            {
                Id = processorModel.Id,
                Name = processorModel.Name,
                Wattage = processorModel.Wattage,
                SocketType = processorModel.SocketType.ToString(),

                DetailType = processorModel.DetailType
            });
        }
        public bool IsPossibleToCreate(CaseModel Case, ProcessorModel Processor, MotherboardModel Motherboard, MemoryCardModel MemoryCard, PowerSupplyModel PowerSupply)
        {
            double SystemWatage            = PowerSupply.CalculateSystemWattage(Processor.Wattage, MemoryCard.Wattage);
            bool   IsCompatiblePowerSupply = PowerSupply.Wattage > SystemWatage;

            bool IsCompatibleWithMB = Motherboard.CheckMemoryCardCompatibility(MemoryCard.MemoryCardType) &&
                                      Motherboard.CheckProcessorCompatibility(Processor.SocketType);

            bool IsCompatibleWithCase = Case.CheckMotherBoardСompatibility(Motherboard.MotherboardType) &&
                                        Case.CheckPowerSupplyСompatibility(PowerSupply.PowerSupplyType);



            return(IsCompatibleWithMB && IsCompatibleWithCase && IsCompatiblePowerSupply);
        }
Exemple #5
0
        private void ExtractBoardVersion()
        {
            var hasSysInfo = DependencyContainer.Current.CanResolve <ISystemInfo>();

            try
            {
                if (string.IsNullOrWhiteSpace(Revision) == false &&
                    int.TryParse(
                        Revision.ToUpperInvariant(),
                        NumberStyles.HexNumber,
                        CultureInfo.InvariantCulture,
                        out var boardVersion))
                {
                    RaspberryPiVersion = PiVersion.Unknown;
                    if (Enum.IsDefined(typeof(PiVersion), boardVersion))
                    {
                        RaspberryPiVersion = (PiVersion)boardVersion;
                    }

                    if ((boardVersion & NewStyleCodesMask) == NewStyleCodesMask)
                    {
                        NewStyleRevisionCodes = true;
                        RevisionNumber        = boardVersion & 0xF;
                        _boardModel           = (BoardModel)((boardVersion >> 4) & 0xFF);
                        _processorModel       = (ProcessorModel)((boardVersion >> 12) & 0xF);
                        _manufacturer         = (Manufacturer)((boardVersion >> 16) & 0xF);
                        _memorySize           = (MemorySize)((boardVersion >> 20) & 0x7);
                    }
                }

                if (hasSysInfo)
                {
                    BoardRevision = (int)DependencyContainer.Current.Resolve <ISystemInfo>().BoardRevision;
                }
            }
            catch
            {
                /* Ignore */
            }

            if (hasSysInfo)
            {
                LibraryVersion = DependencyContainer.Current.Resolve <ISystemInfo>().LibraryVersion;
            }
        }
        public void Preload_test()
        {
            // arrange
            var maker = "Intel";
            var processorSpeed = 500;
            var ramSize = 2000;
            processors[0] = new Dictionary<string, object>
            {
                { "Maker", maker},
                { "Speed", processorSpeed},
                { "RamId", 0 }
            };
            rams[0] = new Dictionary<string, object>
            {
                { "Size", ramSize }
            };
            var aggregatorProvider = aggregatorProviderMock.Object;
            var processorModel = new ProcessorModel(0, processorCollectionMock.Object);
            var ramModel = new RAMModel(0, ramCollectionMock.Object);
            var computer = new Computer(aggregatorProvider, processorModel);
            var ram = new RAM(aggregatorProvider, ramModel);
            aggregatorProvider.Save(computer, ram);

            // act
            computer.PreloadAgg(x => x.Maker,
                                x => x.ProcessorSpeed,
                                x => x.RAM);

            // assert
            computer.RAM.Size.Should().Be(ramSize);
            computer.ProcessorSpeed.Should().Be(processorSpeed);
            computer.Maker.Should().Be(maker);
            processorCollectionMock.Verify(x =>
                x.GetFields(It.IsAny<Id>(), It.IsAny<string[]>()),
                Times.Once);
            processorCollectionMock.Verify(x =>
                x.GetModelField(It.IsAny<Id>(), It.IsAny<string>()),
                Times.Never);
            ramCollectionMock.Verify(x =>
                x.GetFields(It.IsAny<Id>(), It.IsAny<string[]>()),
                Times.Once);
            ramCollectionMock.Verify(x =>
                x.GetModelField(It.IsAny<Id>(), It.IsAny<string>()),
                Times.Never);
        }
Exemple #7
0
        public static void Main(string[] args)
        {
            //примеры работы с моделью.

            ConnectionInterface sata       = new ConnectionInterface("Sata-1");
            ConnectionInterface pciExpress = new ConnectionInterface("PCI-Express");
            ConnectionInterface powerPin   = new ConnectionInterface("PowerPin");
            ConnectionInterface socket     = new ConnectionInterface("AM4");

            MotherboardModel motherboardModel = new MotherboardModel("B450", 2, new List <ConnectionInterface>()
            {
                sata, pciExpress, powerPin, socket
            }, Socket.AM4, FormFactor.MiniATx);
            HardDriveModel hddModel = new HardDriveModel("mega hdd", 4, new List <ConnectionInterface>()
            {
                sata, powerPin
            }, 7200);
            PowerSupplyModel powerSupplyModel = new PowerSupplyModel("PS-8000", 55, new List <ConnectionInterface>()
            {
                powerPin, powerPin, powerPin
            }, 600);
            ProcessorModel processorModel = new ProcessorModel("3600x", 6, new List <ConnectionInterface>()
            {
                socket
            }, 6);

            MotherBoard mother        = new MotherBoard(motherboardModel);
            MotherBoard anotherMother = new MotherBoard(motherboardModel);
            Processor   processor     = new Processor(processorModel);
            PowerSupply powerSupply   = new PowerSupply(powerSupplyModel);
            HardDrive   hardDrive     = new HardDrive(hddModel);

            mother.Establisher.TryToConnect(processor, socket);
            mother.Establisher.TryToConnect(hardDrive, sata);
            mother.Establisher.TryToConnect(powerSupply, powerPin);
            hardDrive.Establisher.TryToConnect(powerSupply, powerPin);

            Hardware       hardware = new Hardware(mother);
            ComputerSystem system   = new ComputerSystem();

            hardDrive.InstallSystem(system);

            //Включение и перезагрузка. Включать можно только через Hardware. Выключать и рестарат через Hardware и ComputerSystem.(like IRL)
            Computer       computer     = new Computer(hardware);
            ComputerSystem loadedSystem = computer.Hardware.TryToTurnOn();

            loadedSystem.Restart();

            //Продажа компьютеров
            ShopCatalog catalog = new ShopCatalog();

            catalog.AddLot(new Lot(computer.Hardware, 100, 2));
            Lot      wantToBuy      = catalog.FindSuitable(x => x.Cost < 150 && x.Item is Hardware).First();
            Hardware boughtHardware = (Hardware)catalog.Buy(wantToBuy);
            Computer boughtComputer = new Computer(boughtHardware);

            //Замена материнской платы
            boughtComputer.Hardware.TryToReplaceComponent(mother, anotherMother);

            //Установка приложения в компьютерном классе
            Application     trojan             = new Application(new byte[228]);
            List <Computer> installedComputers = new List <Computer>()
            {
                boughtComputer
            };
            ComputerClass computerClass = new ComputerClass(installedComputers);

            computerClass.InstallApplicationOnEach(trojan);
            computerClass.Command(x => x.System?.Execute(trojan.BinaryCode));

            // сбор металлолома
            MetalCollector collector = new MetalCollector();

            collector.Collect(boughtComputer);
        }
Exemple #8
0
        protected Boolean SubmitForm()
        {
            StringBuilder formattedHtml         = new StringBuilder();
            StringBuilder formattedInternalHtml = new StringBuilder();
            string        seasonalMonths        = "";

            try
            {
                foreach (ListItem item in cblSeasonal.Items)
                {
                    if (item.Selected)
                    {
                        seasonalMonths += item.Value + " - ";
                    }
                }

                if (seasonalMonths.Length > 3)
                {
                    seasonalMonths = seasonalMonths.Substring(0, seasonalMonths.Length - 3);
                }
            }
            catch (System.Exception ex)
            {
                _newLogic.WriteExceptionToDB(ex, "AdminSubmitForm - Get Seasonal Months");
            }

            try
            {
                //Instanciate new model objects for each piece of data to be created
                MerchantModel          newMerchant                        = new MerchantModel();
                MerchantPrincipalModel newMerchantPrincipal               = new MerchantPrincipalModel();
                ContactModel           newMerchantPrincipalContact        = new ContactModel();
                AddressModel           newMerchantPrincipalContactAddress = new AddressModel();
                ContactModel           newContact         = new ContactModel();
                ContactModel           newBusiness        = new ContactModel();
                AddressModel           newBusinessAddress = new AddressModel();
                ProcessorModel         newProcessor       = new ProcessorModel();
                DebitCardModel         newDebitCard       = new DebitCardModel();
                BankModel        newBankModel             = new BankModel();
                BankAccountModel newBankAccountModel      = new BankAccountModel();

                //Set base merchant information in newMerchant object
                if (txtMerchantId.Text != "")
                {
                    newMerchant.MerchantId = txtMerchantId.Text;
                }
                if (txtCorpName.Text != "")
                {
                    newMerchant.CorpName = txtCorpName.Text;
                }
                if (txtDBAName.Text != "")
                {
                    newMerchant.DbaName = txtDBAName.Text;
                }
                if (txtBusLicNumber.Text != "")
                {
                    newMerchant.BusLicNumber = txtBusLicNumber.Text;
                }
                if (txtBusLicType.Text != "")
                {
                    newMerchant.BusLicType = txtBusLicType.Text;
                }
                if (txtBusLicIssuer.Text != "")
                {
                    newMerchant.BusLicIssuer = txtBusLicIssuer.Text;
                }
                if (radBusLicDate.SelectedDate.HasValue)
                {
                    newMerchant.BusLicDate = Convert.ToDateTime(radBusLicDate.SelectedDate);
                }
                if (txtFedTaxId.Text != "")
                {
                    newMerchant.FedTaxId = txtFedTaxId.Text;
                }
                if (txtMerchandiseSold.Text != "")
                {
                    newMerchant.MerchandiseSold = txtMerchandiseSold.Text;
                }
                if (txtYearsInBus.Text != "")
                {
                    newMerchant.YearsInBusiness = Convert.ToInt32(txtYearsInBus.Text);
                }
                if (txtMonthsInBus.Text != "")
                {
                    newMerchant.MonthsInBusiness = Convert.ToInt32(txtMonthsInBus.Text);
                }
                if (rblSeasonal.SelectedValue != "")
                {
                    newMerchant.SeasonalSales = Convert.ToBoolean(rblSeasonal.SelectedValue);
                }
                if (seasonalMonths != "")
                {
                    newMerchant.SeasonalMonths = seasonalMonths;
                }
                if (txtSwipedPct.Text != "")
                {
                    newMerchant.SwipedPct = Convert.ToInt32(txtSwipedPct.Text);
                }
                if (txtAvgMonthlySales.Text != "")
                {
                    newMerchant.AvgMonthlySales = Convert.ToDecimal(txtAvgMonthlySales.Text);
                }
                if (txtHighestMonthlySales.Text != "")
                {
                    newMerchant.HighestMonthlySales = Convert.ToDecimal(txtHighestMonthlySales.Text);
                }
                if (txtAvgWeeklySales.Text != "")
                {
                    newMerchant.AvgWeeklySales = Convert.ToDecimal(txtAvgWeeklySales.Text);
                }
                if (rblHighRisk.SelectedValue != "")
                {
                    newMerchant.HighRisk = Convert.ToBoolean(rblHighRisk.SelectedValue);
                }
                if (txtHighRiskWho.Text != "")
                {
                    newMerchant.HighRiskWho = txtHighRiskWho.Text;
                }
                if (radHighRiskDate.SelectedDate.HasValue)
                {
                    newMerchant.HighRiskDate = Convert.ToDateTime(radHighRiskDate.SelectedDate);
                }
                if (rblBankruptcy.SelectedValue != "")
                {
                    newMerchant.Bankruptcy = Convert.ToBoolean(rblBankruptcy.SelectedValue);
                }
                if (radBankruptcyDate.SelectedDate.HasValue)
                {
                    newMerchant.BankruptcyDate = Convert.ToDateTime(radBankruptcyDate.SelectedDate);
                }

                //Add Legal Org State to merchant
                if (ddlLegalOrgState.SelectedValue != "")
                {
                    Int32 legalOrgStateId = Convert.ToInt32(ddlLegalOrgState.SelectedValue);
                    newMerchant.LegalOrgState = _globalCtx.GeoStates.Where(gs => gs.RecordId == legalOrgStateId).FirstOrDefault();
                }

                //Add Legal Org Type to merchant
                if (ddlLegalOrgType.SelectedValue != "")
                {
                    Int32 legalOrgTypeId = Convert.ToInt32(ddlLegalOrgType.SelectedValue);
                    newMerchant.LegalOrgType = _globalCtx.LegalOrgTypes.Where(lot => lot.RecordId == legalOrgTypeId).FirstOrDefault();
                }

                //Add Merchant Type to Merchant
                if (rblMerchantType.SelectedValue != "")
                {
                    newMerchant.MerchantType = _globalCtx.MerchantTypes.Where(mt => mt.MerchantTypeName == rblMerchantType.SelectedValue).FirstOrDefault();
                }

                //Add MCC to merchant
                if (ddlMCC.SelectedValue != "")
                {
                    Int32 mccId = Convert.ToInt32(ddlMCC.SelectedValue);
                    newMerchant.Mcc = _globalCtx.MerchantCategoryCodes.Where(mcc => mcc.RecordId == mccId).FirstOrDefault();
                }

                //Add Business Contact info - Email, Phone, Fax
                if (txtBusEmail.Text != "")
                {
                    newBusiness.Email = txtBusEmail.Text;
                }
                if (txtBusFax.Text != "")
                {
                    newBusiness.Fax = txtBusFax.Text;
                }
                if (txtBusPhone.Text != "")
                {
                    newBusiness.HomePhone = txtBusPhone.Text;
                }

                _globalCtx.Contacts.Add(newBusiness);

                //Add Business Contact Addess
                if (txtCorpAddress.Text != "")
                {
                    newBusinessAddress.Address = txtCorpAddress.Text;
                }
                if (txtCorpCity.Text != "")
                {
                    newBusinessAddress.City = txtCorpCity.Text;
                }
                if (ddlCorpState.SelectedValue != "")
                {
                    Int32 businessAddressStateId = Convert.ToInt32(ddlCorpState.SelectedValue);
                    newBusinessAddress.State = _globalCtx.GeoStates.Where(gs => gs.RecordId == businessAddressStateId).FirstOrDefault();
                }
                if (txtCorpZip.Text != "")
                {
                    newBusinessAddress.Zip = txtCorpZip.Text;
                }

                _globalCtx.Addresses.Add(newBusinessAddress);

                //Add new Business Contact Address to new Business
                newBusiness.Address = newBusinessAddress;

                //Add new Contact to new Merchant
                newMerchant.Business = newBusiness;

                //Add new Contact
                if (txtContactFirstName.Text != "")
                {
                    newContact.FirstName = txtContactFirstName.Text;
                }
                if (txtContactLastName.Text != "")
                {
                    newContact.LastName = txtContactLastName.Text;
                }
                if (txtContactEmail.Text != "")
                {
                    newContact.Email = txtContactEmail.Text;
                }
                if (txtContactPhone.Text != "")
                {
                    newContact.HomePhone = txtContactPhone.Text;
                }
                if (txtContactFax.Text != "")
                {
                    newContact.Fax = txtContactFax.Text;
                }

                _globalCtx.Contacts.Add(newContact);

                //Add new contact to new Merchant
                newMerchant.Contact = newContact;

                //Add new Merchant Principal
                if (txtPrincipalDLNumber.Text != "")
                {
                    newMerchantPrincipal.PrincipalDLNumber = PWDTK.StringToUtf8Bytes(txtPrincipalDLNumber.Text);
                }
                if (ddlPrincipalDLState.SelectedValue != "")
                {
                    Int32 dlStateId = Convert.ToInt32(ddlPrincipalDLState.SelectedValue);
                    newMerchantPrincipal.PrincipalDLState = _globalCtx.GeoStates.Where(gs => gs.RecordId == dlStateId).FirstOrDefault();
                }
                if (radPrincipalDoB.SelectedDate.HasValue)
                {
                    newMerchantPrincipal.PrincipalDoB = Convert.ToDateTime(radPrincipalDoB.SelectedDate);
                }
                if (txtPrincipalPctOwn.Text != "")
                {
                    newMerchantPrincipal.PrincipalPctOwn = Convert.ToInt32(txtPrincipalPctOwn.Text);
                }

                _globalCtx.MerchantPrincipal.Add(newMerchantPrincipal);

                //Create new contact for Merchant Principal
                if (txtPrincipalFirstName.Text != "")
                {
                    newMerchantPrincipalContact.FirstName = txtPrincipalFirstName.Text;
                }
                if (txtPrincipalLastName.Text != "")
                {
                    newMerchantPrincipalContact.LastName = txtPrincipalLastName.Text;
                }
                if (txtPrincipalMI.Text != "")
                {
                    newMerchantPrincipalContact.MiddleInitial = txtPrincipalMI.Text;
                }
                if (txtPrincipalTitle.Text != "")
                {
                    newMerchantPrincipalContact.Title = txtPrincipalTitle.Text;
                }
                if (txtPrincipalCellPhone.Text != "")
                {
                    newMerchantPrincipalContact.CellPhone = txtPrincipalCellPhone.Text;
                }
                if (txtPrincipalHomePhone.Text != "")
                {
                    newMerchantPrincipalContact.HomePhone = txtPrincipalHomePhone.Text;
                }

                _globalCtx.Contacts.Add(newMerchantPrincipalContact);

                //Create new address for Merchant principal Contact
                if (txtPrincipalAddress.Text != "")
                {
                    newMerchantPrincipalContactAddress.Address = txtPrincipalAddress.Text;
                }
                if (txtPrincipalCity.Text != "")
                {
                    newMerchantPrincipalContactAddress.City = txtPrincipalCity.Text;
                }
                if (ddlPrincipalState.SelectedValue != "")
                {
                    Int32 mpcStateId = Convert.ToInt32(ddlPrincipalState.SelectedValue);
                    newMerchantPrincipalContactAddress.State = _globalCtx.GeoStates.Where(gs => gs.RecordId == mpcStateId).FirstOrDefault();
                }
                if (txtPrincipalZip.Text != "")
                {
                    newMerchantPrincipalContactAddress.Zip = txtPrincipalZip.Text;
                }

                _globalCtx.Addresses.Add(newMerchantPrincipalContactAddress);

                //Add new address to Merchant Principal Contact
                newMerchantPrincipalContact.Address = newMerchantPrincipalContactAddress;

                //Add new Contact to Merchant Principal
                newMerchantPrincipal.Contact = newMerchantPrincipalContact;

                //Add new Principal to the new merchant
                newMerchant.MerchantPrincipal = newMerchantPrincipal;

                //Check if merchant processor already exists, if so link to merchant.  If not, create it and add to merchant.
                if (txtCardProcessor.Text != "")
                {
                    if (_globalCtx.Processor.Where(p => p.ProcessorName == txtCardProcessor.Text.Trim()).ToList().Count > 0)
                    {
                        newMerchant.Processor = _globalCtx.Processor.First(p => p.ProcessorName == txtCardProcessor.Text.Trim());
                    }
                    else
                    {
                        newProcessor.ProcessorName = txtCardProcessor.Text.Trim();
                        _globalCtx.Processor.Add(newProcessor);
                        newMerchant.Processor = newProcessor;
                    }
                }

                _globalCtx.Banks.Add(newBankModel);

                newBankAccountModel.Bank = newBankModel;
                newDebitCard.Bank        = newBankModel;

                _globalCtx.BankAccounts.Add(newBankAccountModel);
                _globalCtx.DebitCards.Add(newDebitCard);

                newMerchant.BankAccount = newBankAccountModel;
                newMerchant.DebitCard   = newDebitCard;

                //Set Merchant Status to "Admin Registered"
                newMerchant.MerchantStatus = _globalCtx.MerchantStatuses.FirstOrDefault(ms => ms.StatusDescription == "Pre-Enrolled");

                //Set Underwriting Status to "Pending"
                newMerchant.UnderwritingStatus = _globalCtx.UnderwritingStatuses.FirstOrDefault(ms => ms.StatusDescription == "Pending");

                newMerchant.AdvancePlan = _globalCtx.AdvancePlans.First(ap => ap.DefaultPlan == true);

                //Add new Merchant to context
                _globalCtx.Merchants.Add(newMerchant);

                //Add new merchant to selected User
                if (txtSelectedUserName.Text != "")
                {
                    var             manager      = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(_globalCtx));
                    ApplicationUser selectedUser = manager.FindByName(txtSelectedUserName.Text);
                    if (selectedUser != null)
                    {
                        selectedUser.Merchant = newMerchant;

                        //Save Context and Update DB
                        _globalCtx.SaveChanges();
                    }
                }
                else
                {
                    lblSubmissionMessage.Text = "Please select a User to join with this merchant.";
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                _newLogic.WriteExceptionToDB(ex, "AdminSubmitForm - Add Data to DB");
                return(false);
            }

            return(true);
        }
        protected Boolean SubmitForm()
        {
            StringBuilder formattedHtml = new StringBuilder();
            StringBuilder formattedInternalHtml = new StringBuilder();
            string seasonalMonths = "";

            try
            {
                foreach (ListItem item in cblSeasonal.Items)
                {
                    if (item.Selected)
                    {
                        seasonalMonths += item.Value + " - ";
                    }
                }

                if (seasonalMonths.Length > 3)
                {
                    seasonalMonths = seasonalMonths.Substring(0, seasonalMonths.Length - 3);
                }
            }
            catch (System.Exception ex)
            {
                _newLogic.WriteExceptionToDB(ex, "AdminSubmitForm - Get Seasonal Months");
            }

            try
            {
                //Instanciate new model objects for each piece of data to be created
                MerchantModel newMerchant = new MerchantModel();
                MerchantPrincipalModel newMerchantPrincipal = new MerchantPrincipalModel();
                ContactModel newMerchantPrincipalContact = new ContactModel();
                AddressModel newMerchantPrincipalContactAddress = new AddressModel();
                ContactModel newContact = new ContactModel();
                ContactModel newBusiness = new ContactModel();
                AddressModel newBusinessAddress = new AddressModel();
                ProcessorModel newProcessor = new ProcessorModel();
                DebitCardModel newDebitCard = new DebitCardModel();
                BankModel newBankModel = new BankModel();
                BankAccountModel newBankAccountModel = new BankAccountModel();

                //Set base merchant information in newMerchant object
                if (txtMerchantId.Text != "") { newMerchant.MerchantId = txtMerchantId.Text; }
                if (txtCorpName.Text != "") { newMerchant.CorpName = txtCorpName.Text; }
                if (txtDBAName.Text != "") { newMerchant.DbaName = txtDBAName.Text; }
                if (txtBusLicNumber.Text != "") { newMerchant.BusLicNumber = txtBusLicNumber.Text; }
                if (txtBusLicType.Text != "") { newMerchant.BusLicType = txtBusLicType.Text; }
                if (txtBusLicIssuer.Text != "") { newMerchant.BusLicIssuer = txtBusLicIssuer.Text; }
                if (radBusLicDate.SelectedDate.HasValue) { newMerchant.BusLicDate = Convert.ToDateTime(radBusLicDate.SelectedDate); }
                if (txtFedTaxId.Text != "") { newMerchant.FedTaxId = txtFedTaxId.Text; }
                if (txtMerchandiseSold.Text != "") { newMerchant.MerchandiseSold = txtMerchandiseSold.Text; }
                if (txtYearsInBus.Text != "") { newMerchant.YearsInBusiness = Convert.ToInt32(txtYearsInBus.Text); }
                if (txtMonthsInBus.Text != "") { newMerchant.MonthsInBusiness = Convert.ToInt32(txtMonthsInBus.Text); }
                if (rblSeasonal.SelectedValue != "") { newMerchant.SeasonalSales = Convert.ToBoolean(rblSeasonal.SelectedValue); }
                if (seasonalMonths != "") { newMerchant.SeasonalMonths = seasonalMonths; }
                if (txtSwipedPct.Text != "") { newMerchant.SwipedPct = Convert.ToInt32(txtSwipedPct.Text); }
                if (txtAvgMonthlySales.Text != "") { newMerchant.AvgMonthlySales = Convert.ToDecimal(txtAvgMonthlySales.Text); }
                if (txtHighestMonthlySales.Text != "") { newMerchant.HighestMonthlySales = Convert.ToDecimal(txtHighestMonthlySales.Text); }
                if (txtAvgWeeklySales.Text != "") { newMerchant.AvgWeeklySales = Convert.ToDecimal(txtAvgWeeklySales.Text); }
                if (rblHighRisk.SelectedValue != "") { newMerchant.HighRisk = Convert.ToBoolean(rblHighRisk.SelectedValue); }
                if (txtHighRiskWho.Text != "") { newMerchant.HighRiskWho = txtHighRiskWho.Text; }
                if (radHighRiskDate.SelectedDate.HasValue) { newMerchant.HighRiskDate = Convert.ToDateTime(radHighRiskDate.SelectedDate); }
                if (rblBankruptcy.SelectedValue != "") { newMerchant.Bankruptcy = Convert.ToBoolean(rblBankruptcy.SelectedValue); }
                if (radBankruptcyDate.SelectedDate.HasValue) { newMerchant.BankruptcyDate = Convert.ToDateTime(radBankruptcyDate.SelectedDate); }

                //Add Legal Org State to merchant
                if (ddlLegalOrgState.SelectedValue != "")
                {
                    Int32 legalOrgStateId = Convert.ToInt32(ddlLegalOrgState.SelectedValue);
                    newMerchant.LegalOrgState = _globalCtx.GeoStates.Where(gs => gs.RecordId == legalOrgStateId).FirstOrDefault();
                }

                //Add Legal Org Type to merchant
                if (ddlLegalOrgType.SelectedValue != "")
                {
                    Int32 legalOrgTypeId = Convert.ToInt32(ddlLegalOrgType.SelectedValue);
                    newMerchant.LegalOrgType = _globalCtx.LegalOrgTypes.Where(lot => lot.RecordId == legalOrgTypeId).FirstOrDefault();
                }

                //Add Merchant Type to Merchant
                if (rblMerchantType.SelectedValue != "") { newMerchant.MerchantType = _globalCtx.MerchantTypes.Where(mt => mt.MerchantTypeName == rblMerchantType.SelectedValue).FirstOrDefault(); }

                //Add MCC to merchant
                if (ddlMCC.SelectedValue != "")
                {
                    Int32 mccId = Convert.ToInt32(ddlMCC.SelectedValue);
                    newMerchant.Mcc = _globalCtx.MerchantCategoryCodes.Where(mcc => mcc.RecordId == mccId).FirstOrDefault();
                }

                //Add Business Contact info - Email, Phone, Fax
                if (txtBusEmail.Text != "") { newBusiness.Email = txtBusEmail.Text; }
                if (txtBusFax.Text != "") { newBusiness.Fax = txtBusFax.Text; }
                if (txtBusPhone.Text != "") { newBusiness.HomePhone = txtBusPhone.Text; }

                _globalCtx.Contacts.Add(newBusiness);

                //Add Business Contact Addess
                if (txtCorpAddress.Text != "") { newBusinessAddress.Address = txtCorpAddress.Text; }
                if (txtCorpCity.Text != "") { newBusinessAddress.City = txtCorpCity.Text; }
                if (ddlCorpState.SelectedValue != "")
                {
                    Int32 businessAddressStateId = Convert.ToInt32(ddlCorpState.SelectedValue);
                    newBusinessAddress.State = _globalCtx.GeoStates.Where(gs => gs.RecordId == businessAddressStateId).FirstOrDefault();
                }
                if (txtCorpZip.Text != "") { newBusinessAddress.Zip = txtCorpZip.Text; }

                _globalCtx.Addresses.Add(newBusinessAddress);

                //Add new Business Contact Address to new Business
                newBusiness.Address = newBusinessAddress;

                //Add new Contact to new Merchant
                newMerchant.Business = newBusiness;

                //Add new Contact
                if (txtContactFirstName.Text != "") { newContact.FirstName = txtContactFirstName.Text; }
                if (txtContactLastName.Text != "") { newContact.LastName = txtContactLastName.Text; }
                if (txtContactEmail.Text != "") { newContact.Email = txtContactEmail.Text; }
                if (txtContactPhone.Text != "") { newContact.HomePhone = txtContactPhone.Text; }
                if (txtContactFax.Text != "") { newContact.Fax = txtContactFax.Text; }

                _globalCtx.Contacts.Add(newContact);

                //Add new contact to new Merchant
                newMerchant.Contact = newContact;

                //Add new Merchant Principal
                if (txtPrincipalDLNumber.Text != "") { newMerchantPrincipal.PrincipalDLNumber = PWDTK.StringToUtf8Bytes(txtPrincipalDLNumber.Text); }
                if (ddlPrincipalDLState.SelectedValue != "")
                {
                    Int32 dlStateId = Convert.ToInt32(ddlPrincipalDLState.SelectedValue);
                    newMerchantPrincipal.PrincipalDLState = _globalCtx.GeoStates.Where(gs => gs.RecordId == dlStateId).FirstOrDefault();
                }
                if (radPrincipalDoB.SelectedDate.HasValue) { newMerchantPrincipal.PrincipalDoB = Convert.ToDateTime(radPrincipalDoB.SelectedDate); }
                if (txtPrincipalPctOwn.Text != "") { newMerchantPrincipal.PrincipalPctOwn = Convert.ToInt32(txtPrincipalPctOwn.Text); }

                _globalCtx.MerchantPrincipal.Add(newMerchantPrincipal);

                //Create new contact for Merchant Principal
                if (txtPrincipalFirstName.Text != "") { newMerchantPrincipalContact.FirstName = txtPrincipalFirstName.Text; }
                if (txtPrincipalLastName.Text != "") { newMerchantPrincipalContact.LastName = txtPrincipalLastName.Text; }
                if (txtPrincipalMI.Text != "") { newMerchantPrincipalContact.MiddleInitial = txtPrincipalMI.Text; }
                if (txtPrincipalTitle.Text != "") { newMerchantPrincipalContact.Title = txtPrincipalTitle.Text; }
                if (txtPrincipalCellPhone.Text != "") { newMerchantPrincipalContact.CellPhone = txtPrincipalCellPhone.Text; }
                if (txtPrincipalHomePhone.Text != "") { newMerchantPrincipalContact.HomePhone = txtPrincipalHomePhone.Text; }

                _globalCtx.Contacts.Add(newMerchantPrincipalContact);

                //Create new address for Merchant principal Contact
                if (txtPrincipalAddress.Text != "") { newMerchantPrincipalContactAddress.Address = txtPrincipalAddress.Text; }
                if (txtPrincipalCity.Text != "") { newMerchantPrincipalContactAddress.City = txtPrincipalCity.Text; }
                if (ddlPrincipalState.SelectedValue != "")
                {
                    Int32 mpcStateId = Convert.ToInt32(ddlPrincipalState.SelectedValue);
                    newMerchantPrincipalContactAddress.State = _globalCtx.GeoStates.Where(gs => gs.RecordId == mpcStateId).FirstOrDefault();
                }
                if (txtPrincipalZip.Text != "") { newMerchantPrincipalContactAddress.Zip = txtPrincipalZip.Text; }

                _globalCtx.Addresses.Add(newMerchantPrincipalContactAddress);

                //Add new address to Merchant Principal Contact
                newMerchantPrincipalContact.Address = newMerchantPrincipalContactAddress;

                //Add new Contact to Merchant Principal
                newMerchantPrincipal.Contact = newMerchantPrincipalContact;

                //Add new Principal to the new merchant
                newMerchant.MerchantPrincipal = newMerchantPrincipal;

                //Check if merchant processor already exists, if so link to merchant.  If not, create it and add to merchant.
                if (txtCardProcessor.Text != "")
                {
                    if (_globalCtx.Processor.Where(p => p.ProcessorName == txtCardProcessor.Text.Trim()).ToList().Count > 0)
                    {
                        newMerchant.Processor = _globalCtx.Processor.First(p => p.ProcessorName == txtCardProcessor.Text.Trim());
                    }
                    else
                    {
                        newProcessor.ProcessorName = txtCardProcessor.Text.Trim();
                        _globalCtx.Processor.Add(newProcessor);
                        newMerchant.Processor = newProcessor;
                    }
                }

                _globalCtx.Banks.Add(newBankModel);

                newBankAccountModel.Bank = newBankModel;
                newDebitCard.Bank = newBankModel;

                _globalCtx.BankAccounts.Add(newBankAccountModel);
                _globalCtx.DebitCards.Add(newDebitCard);

                newMerchant.BankAccount = newBankAccountModel;
                newMerchant.DebitCard = newDebitCard;

                //Set Merchant Status to "Admin Registered"
                newMerchant.MerchantStatus = _globalCtx.MerchantStatuses.FirstOrDefault(ms => ms.StatusDescription == "Pre-Enrolled");

                //Set Underwriting Status to "Pending"
                newMerchant.UnderwritingStatus = _globalCtx.UnderwritingStatuses.FirstOrDefault(ms => ms.StatusDescription == "Pending");

                newMerchant.AdvancePlan = _globalCtx.AdvancePlans.First(ap => ap.DefaultPlan == true);

                //Add new Merchant to context
                _globalCtx.Merchants.Add(newMerchant);

                //Add new merchant to selected User
                if (txtSelectedUserName.Text != "")
                {
                    var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(_globalCtx));
                    ApplicationUser selectedUser = manager.FindByName(txtSelectedUserName.Text);
                    if (selectedUser != null)
                    {
                        selectedUser.Merchant = newMerchant;

                        //Save Context and Update DB
                        _globalCtx.SaveChanges();
                    }
                }
                else
                {
                    lblSubmissionMessage.Text = "Please select a User to join with this merchant.";
                    return false;
                }
            }
            catch (System.Exception ex)
            {
                _newLogic.WriteExceptionToDB(ex, "AdminSubmitForm - Add Data to DB");
                return false;
            }

            return true;
        }
Exemple #10
0
 void Start()
 {
     GameAct        = new MGameClientAction(this);
     processorModel = new ProcessorModel();
 }
        private void SaveMerchantAccountChanges(MerchantModel editMerchant, ApplicationDbContext ctx)
        {
            try
            {

                foreach (RepeaterItem rItem in rptrMerchantAccountChanges.Items)
                {
                    Label lblFieldName = (Label)rItem.FindControl("lblFieldName4");
                    Label lblNewValue = (Label)rItem.FindControl("lblNewValue4");
                    CheckBox cbConfirmed = (CheckBox)rItem.FindControl("cbConfirmed4");

                    if (lblFieldName != null && lblNewValue != null && cbConfirmed != null)
                    {
                        if (lblFieldName.Text == "Swiped %")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, editMerchant.SwipedPct.Value.ToString() + "%", lblNewValue.Text);

                                editMerchant.SwipedPct = Convert.ToInt32(lblNewValue.Text.Substring(0, lblNewValue.Text.Length - 2));
                            }
                            else
                            {
                                txtSwipedPct.Text = editMerchant.SwipedPct.ToString() ?? "";
                            }
                        }

                        if (lblFieldName.Text == "Avg Monthly Sales")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, "$" + editMerchant.AvgMonthlySales.Value.ToString(), lblNewValue.Text);

                                editMerchant.AvgMonthlySales = Convert.ToDecimal(lblNewValue.Text.Trim().Replace("$", ""));
                            }
                            else
                            {
                                txtAvgMonthlySales.Text = editMerchant.AvgMonthlySales.ToString() ?? "";
                            }
                        }

                        if (lblFieldName.Text == "Highest Monthly Sales")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, "$" + editMerchant.HighestMonthlySales.Value.ToString(), lblNewValue.Text);

                                editMerchant.HighestMonthlySales = Convert.ToDecimal(lblNewValue.Text.Trim().Replace("$", ""));
                            }
                            else
                            {
                                txtHighestMonthlySales.Text = editMerchant.HighestMonthlySales.ToString() ?? "";
                            }
                        }

                        if (lblFieldName.Text == "Avg Weekly Sales")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, "$" + editMerchant.AvgWeeklySales.Value.ToString(), lblNewValue.Text);

                                editMerchant.AvgWeeklySales = Convert.ToDecimal(lblNewValue.Text.Trim().Replace("$", ""));
                            }
                            else
                            {
                                txtAvgWeeklySales.Text = editMerchant.AvgWeeklySales.ToString() ?? "";
                            }
                        }

                        if (lblFieldName.Text == "Processor")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, editMerchant.Processor.ProcessorName, lblNewValue.Text);

                                //Check if merchant processor already exists, if so link to merchant.  If not, create it and add to merchant.
                                if (ctx.Processor.Any(p => p.ProcessorName == txtCardProcessor.Text.Trim()))
                                {
                                    editMerchant.Processor = ctx.Processor.First(p => p.ProcessorName == txtCardProcessor.Text.Trim());
                                }
                                else
                                {
                                    ProcessorModel newProcessor = new ProcessorModel();
                                    newProcessor.ProcessorName = txtCardProcessor.Text;
                                    ctx.Processor.Add(newProcessor);
                                    editMerchant.Processor = newProcessor;
                                }
                            }
                            else
                            {
                                if (editMerchant.Processor != null)
                                {
                                    txtCardProcessor.Text = editMerchant.Processor.ProcessorName;
                                }
                                else
                                {
                                    txtCardProcessor.Text = "";
                                }
                            }
                        }

                        if (lblFieldName.Text == "Merchant Id")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, editMerchant.MerchantId, lblNewValue.Text);

                                editMerchant.MerchantId = lblNewValue.Text.Trim();
                            }
                            else
                            {
                                txtMerchantId.Text = editMerchant.MerchantId ?? "";
                            }
                        }

                        if (lblFieldName.Text == "High Risk")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, editMerchant.HighRisk.Value.ToString(), lblNewValue.Text.Trim());

                                editMerchant.HighRisk = Convert.ToBoolean(lblNewValue.Text.Trim());

                                if (lblNewValue.Text.Trim() == "False")
                                {
                                    editMerchant.HighRiskWho = "";
                                    editMerchant.HighRiskDate = null;
                                    txtHighRiskWho.Text = "";
                                    ddlHighRiskDay.SelectedIndex = -1;
                                    ddlHighRiskMonth.SelectedIndex = -1;
                                    ddlHighRiskYear.SelectedIndex = -1;
                                }
                            }
                            else
                            {
                                if (editMerchant.HighRisk != null)
                                {
                                    rblHighRisk.SelectedValue = editMerchant.HighRisk.ToString();
                                }
                                else
                                {
                                    rblHighRisk.SelectedIndex = -1;
                                }
                            }
                        }

                        if (lblFieldName.Text == "High Risk Who")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, editMerchant.HighRiskWho, lblNewValue.Text.Trim());

                                editMerchant.HighRiskWho = lblNewValue.Text.Trim();
                            }
                            else
                            {
                                txtHighRiskWho.Text = editMerchant.HighRiskWho ?? "";
                            }
                        }

                        if (lblFieldName.Text == "High Risk Date")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, editMerchant.HighRiskDate.Value.ToString(), lblNewValue.Text.Trim());

                                editMerchant.HighRiskDate = Convert.ToDateTime(lblNewValue.Text.Trim());
                            }
                            else
                            {
                                if (editMerchant.HighRiskDate.HasValue)
                                {
                                    ddlHighRiskYear.SelectedValue = editMerchant.HighRiskDate.Value.Year.ToString();
                                    ddlHighRiskMonth.SelectedValue = editMerchant.HighRiskDate.Value.Year.ToString();
                                    ddlHighRiskDay.SelectedValue = editMerchant.HighRiskDate.Value.Year.ToString();
                                }
                                else
                                {
                                    ddlHighRiskYear.SelectedIndex = -1;
                                    ddlHighRiskMonth.SelectedIndex = -1;
                                    ddlHighRiskDay.SelectedIndex = -1;
                                }
                            }
                        }

                        if (lblFieldName.Text == "Bankruptcy")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, editMerchant.Bankruptcy.Value.ToString(), lblNewValue.Text.Trim());

                                editMerchant.Bankruptcy = Convert.ToBoolean(lblNewValue.Text.Trim());

                                if (lblNewValue.Text.Trim() == "False")
                                {
                                    editMerchant.BankruptcyDate = null;
                                    ddlBankruptcyDay.SelectedIndex = -1;
                                    ddlBankruptcyMonth.SelectedIndex = -1;
                                    ddlBankruptcyYear.SelectedIndex = -1;
                                }
                            }
                            else
                            {
                                if (editMerchant.Bankruptcy.HasValue)
                                {
                                    rblBankruptcy.SelectedValue = editMerchant.Bankruptcy.ToString();
                                }
                                else
                                {
                                    rblBankruptcy.SelectedIndex = -1;
                                }
                            }
                        }

                        if (lblFieldName.Text == "Bankruptcy Date")
                        {
                            if (cbConfirmed.Checked)
                            {
                                AddChangeToAudit(editMerchant.RecordId, lblFieldName.Text, editMerchant.BankruptcyDate.Value.ToString(), lblNewValue.Text.Trim());

                                editMerchant.BankruptcyDate = Convert.ToDateTime(lblNewValue.Text.Trim());
                            }
                            else
                            {
                                if (editMerchant.BankruptcyDate.HasValue)
                                {
                                    ddlBankruptcyYear.SelectedValue = editMerchant.BankruptcyDate.Value.Year.ToString();
                                    ddlBankruptcyMonth.SelectedValue = editMerchant.BankruptcyDate.Value.Year.ToString();
                                    ddlBankruptcyDay.SelectedValue = editMerchant.BankruptcyDate.Value.Year.ToString();
                                }
                                else
                                {
                                    ddlBankruptcyYear.SelectedIndex = -1;
                                    ddlBankruptcyMonth.SelectedIndex = -1;
                                    ddlBankruptcyDay.SelectedIndex = -1;
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                string userId = "";

                if (Request.IsAuthenticated)
                {
                    userId = Page.User.Identity.GetUserId();
                }
                _newLogic.WriteExceptionToDB(ex, "SaveMerchantAccountChanges", 0, editMerchant.RecordId, userId);
            }
        }
 public Computer(IAggregatorProvider aggProvider, ProcessorModel processor)
     : base(aggProvider, processor)
 {
 }
        public void Set_test()
        {
            // arrange
            var maker = "Intel";
            var processorSpeed = 500;
            var ramSize = 2000;
            processors[0] = new Dictionary<string, object>
            {
                { "Maker", maker},
                { "Speed", processorSpeed},
                { "RamId", 0 }
            };
            rams[0] = new Dictionary<string, object>
            {
                { "Size", ramSize }
            };
            var aggregatorProvider = aggregatorProviderMock.Object;
            var processorModel = new ProcessorModel(0, processorCollectionMock.Object);
            var ramModel = new RAMModel(0, ramCollectionMock.Object);
            var computer = new Computer(aggregatorProvider, processorModel);
            var ram = new RAM(aggregatorProvider, ramModel);
            aggregatorProvider.Save(computer, ram);

            // act
            var newMaker = "AMD";
            var newProcessorSpeed = 1000;
            var newRamSize = 3000;
            computer.RAM.Size = newRamSize;
            computer.ProcessorSpeed = newProcessorSpeed;
            computer.Maker = newMaker;
            computer.Commit();

            // assert
            processors[0]["Maker"].Should().Be(newMaker);
            processors[0]["Speed"].Should().Be(newProcessorSpeed);
            rams[0]["Size"].Should().Be(newRamSize);
            processorCollectionMock.Verify(x =>
                x.UpdateFields(It.IsAny<Id>(), It.IsAny<IDictionary<string, object>>()),
                Times.Once);
            ramCollectionMock.Verify(x =>
                x.UpdateFields(It.IsAny<Id>(), It.IsAny<IDictionary<string, object>>()),
                Times.Once);
        }