public bool Update(IPODetailsDto entity)
        {
            IPODetail iPODetail = new IPODetail()
            {
                IPODetailID      = entity.IPODetailID,
                CompanyId        = entity.CompanyId,
                StockExchangeId  = entity.StockExchangeId,
                OpenDate         = entity.OpenDate,
                OpenTime         = entity.OpenTime,
                TotalNumOfShares = entity.TotalNumOfShares,
                PricePerShare    = entity.PricePerShare,
                Remarks          = entity.Remarks,
            };

            iPODetail.Company       = context.Companies.Find(entity.CompanyId);
            iPODetail.StockExchange = context.StockExchanges.Find(entity.StockExchangeId);

            context.Entry(iPODetail).State = EntityState.Modified;
            var x = context.SaveChanges();

            if (x > 0)
            {
                return(true);
            }
            return(false);
        }
        public bool Update(CompanyDto entity)
        {
            var comp = new Company()
            {
                CompanyId        = entity.CompanyId,
                CompanyName      = entity.CompanyName,
                BoardOfDirectors = entity.BoardOfDirectors,
                CEO      = entity.CEO,
                Brief    = entity.Brief,
                Turnover = entity.Turnover
            };
            var sector = context.Sectors.Find(entity.SectorId);

            comp.Sector = sector;
            context.Entry(comp).State = EntityState.Modified;

            sector.Companies.Add(comp);
            context.Sectors.Update(sector);

            //ICollection<StockExchangeCompany> secList = new HashSet<StockExchangeCompany>();

            //var abc = context.StockExchangeCompanies.Where(s => s.CompanyId == comp.CompanyId);
            //foreach (var a in abc)
            //{
            //    context.StockExchangeCompanies.Remove(a);
            //}

            //for (int i = 0; i < entity.StockExchangeIds.Count(); i++)
            //{
            //    var sid = entity.StockExchangeIds[i];
            //    var sec = new StockExchangeCompany
            //    {
            //        Company = comp,
            //        StockExchange = context.StockExchanges.Find(sid)
            //    };

            //    var ab = context.StockExchangeCompanies.Find(comp.CompanyId,sid);
            //    //if (ab == null)
            //    //{
            //    //    secList.Add(sec);
            //    //}
            //    context.StockExchangeCompanies.Add(sec);
            //}
            //comp.StockExchangeCompanies = secList;
            //context.Entry(comp).State = EntityState.Modified;

            var x = context.SaveChanges();

            if (x > 0)
            {
                return(true);
            }
            return(false);
        }