コード例 #1
0
        private VotingByHand CreateVotingByHand(ShareHolder shareHolder, VotingOption option)
        {
            var shId   = shareHolder.ShareHolderId;
            var voting = new VotingByHand()
            {
                Id              = shareHolder.ShareHolderId,
                NumberOfShares  = shareHolder.NumberOfShares,
                ShareHolderCode = shareHolder.ShareHolderCode,
                ShareHolderId   = shareHolder.ShareHolderId,
                ShareHolderName = shareHolder.Name
            };

            voting.VotingByHandLines.Add(
                new VotingByHandLine()
            {
                Id            = shId * 100,
                StatementId   = 1,
                StatementDesc = "BC HDQT",
                VotingOption  = option
            });


            voting.VotingByHandLines.Add(
                new VotingByHandLine()
            {
                Id            = shId * 100 + 1,
                StatementId   = 2,
                StatementDesc = "BC BTGD",
                VotingOption  = option
            });

            return(voting);
        }
コード例 #2
0
        public HttpResponseMessage Post([FromBody] ShareHolder shareHolder)
        {
            //Validate and returnn errors if any
            var response    = new HttpResponseMessage();
            var brokerRules = _shareHolderValidator.BrokenRules(shareHolder);

            if (brokerRules.Count() > 0)
            {
                var message = CoreHelper.MergeErrors(brokerRules);
                response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, message);
                return(response);
            }

            //Persist
            try
            {
                _context.ShareHolders.Add(shareHolder);
                _context.SaveChanges();
                response = Request.CreateResponse <ShareHolder>(HttpStatusCode.Created, shareHolder);
                response.Headers.Location = new Uri(Request.RequestUri, "/Api/ShareHolderDS/" + shareHolder.ShareHolderId.ToString());
            }
            catch (Exception ex)
            {
                response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message, ex);
            }
            return(response);
        }
コード例 #3
0
        public void Init()
        {
            _votingByHands = new List <VotingByHand>();

            //Adding the FIRST votingByHand
            var shareHolder = new ShareHolder()
            {
                ShareHolderId   = 1,
                NumberOfShares  = 1000,
                Name            = "Long",
                ShareHolderCode = "01"
            };
            var voting = CreateVotingByHand(shareHolder, VotingOption.Yes);

            _votingByHands.Add(voting);

            //Adding the SECOND votingByHand
            var shareHolder2 = new ShareHolder()
            {
                ShareHolderId   = 2,
                NumberOfShares  = 2000,
                Name            = "Diem",
                ShareHolderCode = "02"
            };

            var voting2 = CreateVotingByHand(shareHolder2, VotingOption.Yes);

            _votingByHands.Add(voting2);
        }
コード例 #4
0
        public HttpResponseMessage Put([FromBody] ShareHolder shareHolder)
        {
            //Validate and Return Errors
            var response    = new HttpResponseMessage();
            var brokerRules = _shareHolderValidator.BrokenRules(shareHolder);

            if (brokerRules.Count() > 0)
            {
                var message = CoreHelper.MergeErrors(brokerRules);
                response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, message);
                return(response);
            }
            var entity = _context.ShareHolders.Find(shareHolder.ShareHolderId);

            if (entity == null)
            {
                response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"ShareHolder {shareHolder.ShareHolderId} not found");
                return(response);
            }
            //Persist
            try
            {
                entity.Name            = shareHolder.Name;
                entity.NumberOfShares  = shareHolder.NumberOfShares;
                entity.ShareHolderCode = shareHolder.ShareHolderCode;

                _context.SaveChanges();
                response = Request.CreateResponse <ShareHolder>(HttpStatusCode.OK, shareHolder);
            }
            catch (Exception ex)
            {
                response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
            }
            return(response);
        }
コード例 #5
0
ファイル: VotingCard_Test.cs プロジェクト: longtduc/sh
        public void Init()
        {
            _candidates = new List <Candidate>();
            _candidates.Add(new Candidate()
            {
                Id = 1, Name = "Danh", CandidateType = CandidateType.BODCandidate
            });
            _candidates.Add(new Candidate()
            {
                Id = 2, Name = "Khoi", CandidateType = CandidateType.BODCandidate
            });
            _candidates.Add(new Candidate()
            {
                Id = 3, Name = "Long", CandidateType = CandidateType.BOSCandidate
            });
            _candidates.Add(new Candidate()
            {
                Id = 4, Name = "Duc", CandidateType = CandidateType.BOSCandidate
            });

            _shareHolder = new ShareHolder()
            {
                ShareHolderId   = 1,
                Name            = "Co Dong",
                NumberOfShares  = 1000,
                ShareHolderCode = "01",
                StatusAtMeeting = StatusAtMeeting.Attended
            };
        }
コード例 #6
0
ファイル: VotingResultView_Test.cs プロジェクト: longtduc/sh
 public void Init()
 {
     //Create two ShareHolder
     _shareHolder = new ShareHolder()
     {
         ShareHolderId   = 1,
         Name            = "Long",
         ShareHolderCode = "01",
         NumberOfShares  = 1000,
         StatusAtMeeting = StatusAtMeeting.Attended
     };
     _shareHolder2 = new ShareHolder()
     {
         ShareHolderId   = 2,
         Name            = "Diem",
         ShareHolderCode = "02",
         NumberOfShares  = 1000,
         StatusAtMeeting = StatusAtMeeting.Attended
     };
     //Create a list of Candidates
     _candidates = new List <Candidate>();
     _candidates.Add(new Candidate()
     {
         Id = 1, Name = "A", CandidateType = CandidateType.BODCandidate
     });
     _candidates.Add(new Candidate()
     {
         Id = 2, Name = "B", CandidateType = CandidateType.BODCandidate
     });
     _candidates.Add(new Candidate()
     {
         Id = 3, Name = "C", CandidateType = CandidateType.BOSCandidate
     });
 }
コード例 #7
0
 void Awake()
 {
     variables      = GameObject.FindObjectOfType(typeof(Variables)) as Variables;
     shareHolder    = GameObject.FindObjectOfType(typeof(ShareHolder)) as ShareHolder;
     lastTradesList = GameObject.FindObjectOfType(typeof(LastTradesList)) as LastTradesList;
     buyOrder       = GameObject.FindObjectOfType(typeof(BuyOrder)) as BuyOrder;
     sellOrder      = GameObject.FindObjectOfType(typeof(SellOrder)) as SellOrder;
 }
コード例 #8
0
 void Start()
 {
     buyOrder    = GameObject.FindObjectOfType(typeof(BuyOrder)) as BuyOrder;
     sellOrder   = GameObject.FindObjectOfType(typeof(SellOrder)) as SellOrder;
     shareHolder = GameObject.FindObjectOfType(typeof(ShareHolder)) as ShareHolder;
     variables   = GameObject.FindObjectOfType(typeof(Variables)) as Variables;
     InvokeRepeating("Buy", 3, 5);
     InvokeRepeating("Sell", 5, 3);
     InvokeRepeating("Limit", 3, 3);
 }
コード例 #9
0
 void Start()
 {
     variables      = GameObject.FindObjectOfType(typeof(Variables)) as Variables;
     buyOrder       = GameObject.FindObjectOfType(typeof(BuyOrder)) as BuyOrder;
     sellOrder      = GameObject.FindObjectOfType(typeof(SellOrder)) as SellOrder;
     loanController = GameObject.FindObjectOfType(typeof(LoanController)) as LoanController;
     shareHolder    = GameObject.FindObjectOfType(typeof(ShareHolder)) as ShareHolder;
     InvokeRepeating("Buy", 3, 2);
     InvokeRepeating("Sell", 3, 2);
     InvokeRepeating("GiveLoan", 10, 10);
 }
コード例 #10
0
        private void CreateVotingCardsAndVotingByHands(ShareHolder sh)
        {
            //Create VotingCard for BOD,BOS
            var candidates = _context.Candidates.ToList();

            sh.CreateVotingCards(candidates);

            var statements = _context.Statements.ToList();

            sh.CreateVotingByHands(statements);
        }
コード例 #11
0
    void Start()
    {
        Init();
        sellOrder   = GameObject.FindObjectOfType(typeof(SellOrder)) as SellOrder;
        shareHolder = GameObject.FindObjectOfType(typeof(ShareHolder)) as ShareHolder;
        variables   = GameObject.FindObjectOfType(typeof(Variables)) as Variables;
        var order = new LoanController(shareHolder.companyName, 15, 15, 1.07f, 15);

        loanList.Add(order);
        InvokeRepeating("DisplayLoans", 1, 1);
    }
コード例 #12
0
ファイル: ShareHolderRepo.cs プロジェクト: longtduc/sh
 public void InsertOrUpdate(ShareHolder entity)
 {
     if (entity.ShareHolderId == default(int))
     {
         // New entity
         _context.ShareHolders.Add(entity);
     }
     else
     {
         // Existing entity
         //_context.Entry(entity).State = System.Data.Entity.EntityState.Modified; //Notes
     }
 }
コード例 #13
0
ファイル: VotingByHand_Test.cs プロジェクト: longtduc/sh
 public void Init()
 {
     _shareHolder = new ShareHolder()
     {
         ShareHolderId = 1, Name = "Long", NumberOfShares = 1000, ShareHolderCode = "01", StatusAtMeeting = StatusAtMeeting.Attended
     };
     _statements = new List <Statement>();
     _statements.Add(new Statement()
     {
         Id = 1, Description = "BC KQKD"
     });
     _statements.Add(new Statement()
     {
         Id = 2, Description = "BC BKS"
     });
 }
コード例 #14
0
        public void ChangeShareHolderStatus(int shareHolderId, int newStatus)
        {
            ShareHolder sh = _context.ShareHolders
                             .Include("VotingCards")
                             .Include("VotingByHands")
                             .Where(s => s.ShareHolderId == shareHolderId)
                             .FirstOrDefault();
            var newStatusInEnum = (StatusAtMeeting)newStatus;

            if (sh == null || sh.StatusAtMeeting == newStatusInEnum)
            {
                return;
            }

            if ((sh.StatusAtMeeting == StatusAtMeeting.Attended && newStatusInEnum == StatusAtMeeting.Delegated) ||
                sh.StatusAtMeeting == StatusAtMeeting.Delegated && newStatusInEnum == StatusAtMeeting.Attended)
            {
                sh.StatusAtMeeting = newStatusInEnum;
                _context.SaveChanges();
                return;
            }

            //Update Status
            sh.StatusAtMeeting = newStatusInEnum;
            StatusAtMeeting newStateInEnum = (StatusAtMeeting)newStatus;

            switch (newStateInEnum)
            {
            case StatusAtMeeting.Absent:
                //sh.RemoveAllVotingCardsAndVotingByHands();
                _context.RemoveVotingCardsAndVotingByHands(sh.ShareHolderId);
                break;

            case StatusAtMeeting.Attended:
                CreateVotingCardsAndVotingByHands(sh);
                break;

            case StatusAtMeeting.Delegated:
                CreateVotingCardsAndVotingByHands(sh);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            _context.SaveChanges();
        }
コード例 #15
0
ファイル: ShareHolderRepo.cs プロジェクト: longtduc/sh
        public void RemoveAllVotingCardsAndVotingByHands(ShareHolder entity)
        {
            if (_context != null)
            {
                //_context.Entry(entity).State = System.Data.Entity.EntityState.Modified; //Notes
                //Note: Error message "Collection was modified; enumeration operation may not execute"
                //Fix: entity.VotingCards => entity.VotingCards.ToList()
                foreach (var item in entity.VotingCards.ToList())
                {
                    //_context.Entry(item).State = System.Data.Entity.EntityState.Deleted; //Notes
                }
            }

            foreach (var item in entity.VotingByHands.ToList())
            {
                //_context.Entry(item).State = System.Data.Entity.EntityState.Deleted; //Notes
            }
        }
コード例 #16
0
 void Start()
 {
     SetPriceText();
     SetAmountText();
     SetLoanFundsText();
     Hour           = 0;
     Day            = 1;
     buyOrder       = GameObject.FindObjectOfType(typeof(BuyOrder)) as BuyOrder; //Funciona!!!!! Sirve para poder llamar funciones de otros scripts
     sellOrder      = GameObject.FindObjectOfType(typeof(SellOrder)) as SellOrder;
     loanController = GameObject.FindObjectOfType(typeof(LoanController)) as LoanController;
     shareHolder    = GameObject.FindObjectOfType(typeof(ShareHolder)) as ShareHolder;
     lastTradesList = GameObject.FindObjectOfType(typeof(LastTradesList)) as LastTradesList;
     matchEngine    = GameObject.FindObjectOfType(typeof(MatchEngine)) as MatchEngine;
     InvokeRepeating("DistributeBalance", 1, 1);
     InvokeRepeating("GetData", 5, 5);
     InvokeRepeating("SetMarketData", 1, 1);
     InvokeRepeating("GetTime", 1, 1);
     InvokeRepeating("TimeContador", 0.1f, 0.1f);
 }
コード例 #17
0
ファイル: ShareHolderService.cs プロジェクト: longtduc/sh
        public void ChangeShareHolderStatus(int shareHolderId, int newStatus)
        {
            ShareHolder sh = _shareHolderRepo.Find(shareHolderId);
            var         newStatusInEnum = (StatusAtMeeting)newStatus;

            if (sh == null || sh.StatusAtMeeting == newStatusInEnum)
            {
                return;
            }

            if ((sh.StatusAtMeeting == StatusAtMeeting.Attended && newStatusInEnum == StatusAtMeeting.Delegated) ||
                sh.StatusAtMeeting == StatusAtMeeting.Delegated && newStatusInEnum == StatusAtMeeting.Attended)
            {
                sh.StatusAtMeeting = newStatusInEnum;
                _shareHolderRepo.Save();
                return;
            }

            //Update Status
            sh.StatusAtMeeting = newStatusInEnum;
            StatusAtMeeting newStateInEnum = (StatusAtMeeting)newStatus;

            switch (newStateInEnum)
            {
            case StatusAtMeeting.Absent:
                sh.RemoveAllVotingCardsAndVotingByHands();
                break;

            case StatusAtMeeting.Attended:
                CreateVotingCardsAndVotingByHands(sh);
                break;

            case StatusAtMeeting.Delegated:
                CreateVotingCardsAndVotingByHands(sh);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            _shareHolderRepo.Save();
        }
コード例 #18
0
    public void Start()
    {
        shareHolder = GameObject.FindObjectOfType(typeof(ShareHolder)) as ShareHolder;
        variables   = GameObject.FindObjectOfType(typeof(Variables)) as Variables;
        matchEngine = GameObject.FindObjectOfType(typeof(MatchEngine)) as MatchEngine;
        Init();
        //var order0 = new SellOrder(shareHolder.companyName, 400000, 320, 0.0008f, variables.timeContador);
        var order = new SellOrder("Limit", 1, 9999999, 9999999, variables.timeContador);

        sellOrders.Add(order);
        //sellOrders.Add(order0);

        for (int i = 0; i < 20; i++)
        {
            var orderi = new SellOrder(shareHolder.companyName, 100000 * i, 100000 * i * 0.0008f * i, 0.0008f * i, variables.timeContador);
            sellOrders.Add(orderi);
        }

        sellOrders.Sort((p1, p2) => p1.Price.CompareTo(p2.Price));
        DisplaySellList();
    }
コード例 #19
0
    void Start()
    {
        Init();
        variables          = GameObject.FindObjectOfType(typeof(Variables)) as Variables;
        companyName        = "Moon Funding";
        playerName         = "Pablo Galve";
        IAMarketMaker1name = "Victor";
        IAMarketMaker2name = "Elena";

        var user  = new ShareHolder(companyName, 50000000, 12000, 0, 0, 0, 15, 0, 0, 0);
        var user1 = new ShareHolder("John", 0, 2000, 0, 0, 0, 0, 0, 0, 0);
        var user2 = new ShareHolder("Albert", 0, 3000, 0, 0, 0, 0, 0, 0, 0);
        var user3 = new ShareHolder(playerName, 0, 1000, 0, 0, 0, 0, 0, 0, 0);
        var user4 = new ShareHolder(IAMarketMaker1name, 0, 1000, 0, 0, 0, 0, 0, 0, 0);
        var user5 = new ShareHolder(IAMarketMaker2name, 1000, 1000, 0, 0, 0, 0, 0, 0, 0);
        var user6 = new ShareHolder("Limit", 1, 1000, 0, 0, 0, 0, 0, 0, 0);

        ShareholdersList.Add(user);
        ShareholdersList.Add(user1);
        ShareholdersList.Add(user2);
        ShareholdersList.Add(user3);
        ShareholdersList.Add(user4);
        ShareholdersList.Add(user5);
        ShareholdersList.Add(user6);

        int j = 0;

        foreach (var ShareHolder in ShareholdersList)
        {
            ShareholdersList[j].AvailableShares = ShareholdersList[j].Shares;
            ShareholdersList[j].AvailableFunds  = ShareholdersList[j].Funds;
            j++;
        }
        ShareholdersList[1].AvailableFunds  -= 5.75f;
        ShareholdersList[2].AvailableFunds  -= 1.795f;
        ShareholdersList[0].AvailableShares -= 35000000;
        ShareHolders();
    }
コード例 #20
0
    public void Start()
    {
        shareHolder = GameObject.FindObjectOfType(typeof(ShareHolder)) as ShareHolder;
        variables   = GameObject.FindObjectOfType(typeof(Variables)) as Variables;
        matchEngine = GameObject.FindObjectOfType(typeof(MatchEngine)) as MatchEngine;
        Init();
        var order3 = new BuyOrder("Alberto", 20, 0.008f, 0.0004f, variables.timeContador);
        var order4 = new BuyOrder("Alberto", 200, 0.04f, 0.0002f, variables.timeContador);
        var order5 = new BuyOrder("Pepe", 5000, 0.5f, 0.0001f, variables.timeContador);
        var order6 = new BuyOrder("Alberto", 20, 0.006f, 0.0003f, variables.timeContador);
        var order7 = new BuyOrder("Alberto", 5, 0.0035f, 0.0007f, variables.timeContador);
        var order8 = new BuyOrder("Pepe", 37, 0.01295f, 0.00035f, variables.timeContador);
        var order9 = new BuyOrder("Limit", 10000000, 1000, 0.0001f, variables.timeContador);

        buyOrders.Add(order3);
        buyOrders.Add(order4);
        buyOrders.Add(order5);
        buyOrders.Add(order6);
        buyOrders.Add(order7);
        buyOrders.Add(order8);
        buyOrders.Add(order9);
        buyOrders.Sort((p1, p2) => - p1.Price.CompareTo(p2.Price));
        DisplayBuyList();
    }
コード例 #21
0
 private static void AddPrivateEntityMember(Application application, ShareHolder shareHolder)
 {
     application.PrivateEntity.PersonHoldsSharesInPrivateEntities.Add(
         new PersonHoldsSharesInPrivateEntity(application.PrivateEntity, shareHolder));
 }
コード例 #22
0
 public PersonRepresentsPerson(ShareHolder nominee, ShareHolder beneficiary)
 {
     Nominee     = nominee;
     Beneficiary = beneficiary;
 }
コード例 #23
0
 public PersonRepresentsForeignEntity(ForeignEntity beneficiary, ShareHolder nominee)
 {
     Beneficiary = beneficiary;
     Nominee     = nominee;
 }
コード例 #24
0
ファイル: VotingByHandServices.cs プロジェクト: longtduc/sh
        public void CreateVotingByHand(ShareHolder shareHolder, List <Statement> statements)
        {
            var votingByHand = new VotingByHand(shareHolder, statements);

            _context.VotingByHands.Add(votingByHand);
        }
コード例 #25
0
 public PersonHoldsSharesInPrivateEntity(PrivateEntity privateEntity, ShareHolder shareHolder)
 {
     PrivateEntitySubscribed = privateEntity;
     ShareHolder             = shareHolder;
 }
コード例 #26
0
 public PersonSubscription(ShareHolder shareHolder, ShareClause shareClause, int amountOfSharesSubscribed)
 {
     ShareHolder = shareHolder;
     ShareClause = shareClause;
     AmountOfSharesSubscribed = amountOfSharesSubscribed;
 }
 public PersonRepresentsPrivateEntity(PrivateEntity beneficiary, ShareHolder nominee)
 {
     Beneficiary = beneficiary;
     Nominee     = nominee;
 }