Example #1
0
        public (bool, int) InsertNewIPODetail(IPODetailsDto ipo_dto)
        {
            var existing_company = company_service.GetExistingCompany(ipo_dto.RegisteredCompanyId);

            if (existing_company == null)
            {
                return(false, 1);
            }

            var existing_stockexchange = se_service.GetExistingStockExchange(ipo_dto.RegisteredStockExchangeId);

            if (existing_stockexchange == null)
            {
                return(false, 2);
            }

            var ipo = new IPODetails
            {
                PricePerShare           = ipo_dto.PricePerShare,
                TotalShares             = ipo_dto.TotalShares,
                OfferingDateTime        = Convert.ToDateTime(ipo_dto.OfferingDate + " " + ipo_dto.OfferingTime),
                Remarks                 = ipo_dto.Remarks,
                RegisteredCompany       = existing_company,
                RegisteredStockExchange = existing_stockexchange
            };

            bool add_company_se_relationship =
                se_service.AddRelationshipWithCompany(new JoinCompanyStockExchange
            {
                Company = existing_company, StockExchange = existing_stockexchange
            });

            if (!add_company_se_relationship)
            {
                return(false, 3);
            }

            bool added = repository.Add(ipo);

            return(added, 0);
        }