Пример #1
0
        public async Task <Roundtrip> GetByRoundtripId(string roundtripId)
        {
            var roundtrip = await _context.Roundtrips
                            .Where(i => i.RoundtripId == roundtripId)
                            .SingleOrDefaultAsync();

            if (roundtrip != null)
            {
                await _context.Entry(roundtrip)
                .Reference(r => r.RoundtripStatus).LoadAsync();
            }

            return(roundtrip);
        }
Пример #2
0
        public async Task <IActionResult> PutRoundtrip([FromRoute] int id, [FromBody] Roundtrip roundtrip)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != roundtrip.Id)
            {
                return(BadRequest());
            }

            _context.Entry(roundtrip).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RoundtripExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #3
0
        public async Task <Fund> GetByFundId(string fundId)
        {
            var fund = await _context.Funds
                       .Include(f => f.InvestingFunds)
                       .Where(i => i.FundId == fundId)
                       .SingleOrDefaultAsync();

            if (fund != null)
            {
                foreach (var investingFund in fund.InvestingFunds)
                {
                    await _context.Entry(investingFund)
                    .Reference(i => i.InvestingFundStatus).LoadAsync();
                }
            }

            return(fund);
        }
Пример #4
0
        public async Task <Investment> GetByInvestmentId(string investmentId)
        {
            var investment = await _context.Investments
                             .Where(i => i.InvestmentId == investmentId)
                             .Include(i => i.InvestmentRoundtrips)
                             .SingleOrDefaultAsync();

            if (investment != null)
            {
                await _context.Entry(investment)
                .Reference(i => i.InvestmentStatus).LoadAsync();

                await _context.Entry(investment)
                .Reference(i => i.InvestmentType).LoadAsync();
            }

            return(investment);
        }