public static ValuationReport Generate(string valuationId, string party1Name, string party2Name,
                                               bool isParty1Base, Trade trade, Market market,
                                               AssetValuation assetValuation)
        {
            var valuationReport = new ValuationReport
            {
                header = new NotificationMessageHeader
                {
                    messageId = new MessageId
                    {
                        Value = valuationId
                    }
                },
                market = market
            };
            //  Associate id with the valuation
            //
            var tradeValuationItem = new TradeValuationItem();

            valuationReport.tradeValuationItem = new[] { tradeValuationItem };
            string baseParty = isParty1Base ? party1Name : party2Name;
            Party  party1    = PartyFactory.Create("Party1", party1Name);
            Party  party2    = PartyFactory.Create("Party2", party2Name);

            valuationReport.party           = new[] { party1, party2 };
            tradeValuationItem.Items        = new object[] { trade };
            tradeValuationItem.valuationSet = new ValuationSet
            {
                baseParty      = PartyReferenceFactory.Create(baseParty),
                assetValuation = new[] { assetValuation }
            };
            return(valuationReport);
        }
Esempio n. 2
0
        public void PassingTest()
        {
            var partyFactory = new PartyFactory();

            var theA = (Person)partyFactory.CreatePersonal("A");

            Assert.Equal("Hi, I'am A", theA.Hi());
        }
Esempio n. 3
0
        public void Create_Personal()
        {
            var dbContextScopeFactory   = new DbContextScopeFactory();
            var ambientDbContextLocator = new AmbientDbContextLocator();

            using (var dbContextScope = dbContextScopeFactory.Create())
            {
                var partyFactory = new PartyFactory();
                var dingP        = partyFactory.CreatePersonal("ding.p");

                var partyRepo = new PersonRepository(ambientDbContextLocator);
                partyRepo.Add(dingP);

                dbContextScope.SaveChanges();
            }
        }
Esempio n. 4
0
        public void Test_Mehdime_Entity()
        {
            //-- Poor-man DI - build our dependencies by hand for this demo
            var dbContextScopeFactory   = new DbContextScopeFactory();
            var ambientDbContextLocator = new AmbientDbContextLocator();

            var orderRepository  = new OrderRepository(ambientDbContextLocator);
            var personRepository = new PersonRepository(ambientDbContextLocator);

            var partyFactory = new PartyFactory();
            var orderFactory = new OrderFactory();

            var ddshop = new DDShop(
                dbContextScopeFactory,
                partyFactory,
                orderFactory,
                personRepository,
                orderRepository);

            using (var dbContextScope = dbContextScopeFactory.CreateWithTransaction(IsolationLevel.ReadCommitted))
            {
                var theOrder = orderRepository.Get(1);
                var member   = personRepository.GetByName("ding.p");

                var orderModel = ddshop.NewOrder(member.ID);

                dbContextScope.SaveChanges();
            }

            using (var dbContextScope = dbContextScopeFactory.CreateWithTransaction(IsolationLevel.ReadCommitted))
            {
                /*var orderRepository = new OrderRepository(ambientDbContextLocator);
                 * var personRepository = new PersonRepository(ambientDbContextLocator);
                 *
                 * var ddshop = new DDShop(
                 *  dbContextScopeFactory,
                 *  personRepository, orderRepository);*/

                var theOrder = orderRepository.Get(1);
                var member   = personRepository.GetByName("ding.p");

                var orderModel = ddshop.NewOrder(member.ID);

                dbContextScope.SaveChanges();
            }
        }
Esempio n. 5
0
        internal static void ReplacePartiesInValuationReport(ValuationReport valuationReport, List <PartyIdRangeItem> partyIdList)
        {
            if (null == partyIdList)
            {
                return;
            }
            var listOfParties = new List <Party>();

            foreach (PartyIdRangeItem partyIdRangeItem in partyIdList)
            {
                Party party   = PartyFactory.Create(partyIdRangeItem.IdOrRole);
                var   partyId = new PartyId {
                    Value = partyIdRangeItem.PartyId
                };
                party.partyId = new[] { partyId };
                listOfParties.Add(party);
            }
            valuationReport.party = listOfParties.ToArray();
        }
Esempio n. 6
0
        public static void DataInit()
        {
            PartyFactory factory = new PartyFactory();

            cParty = factory.MakeCParty();
            gParty = factory.MakeGParty();
            sParty = factory.MakeSParty();
            lParty = factory.MakeLParty();
            nParty = factory.MakeNParty();
            IParty[] ps = new IParty[] {
                cParty, gParty, sParty, lParty, nParty
            };
            // sort ps using p.Id as key
            // maybe this can help improve performance
            Array.Sort(ps, ps.Select(p => p.Id).ToArray());
            Parties = ps;

            Government.Start();
            Government.Instance.UpdateSeats(Election.CurrentElectionInfo);
        }