public async Task <IActionResult> GetOpportunity([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Opportunity opportunity = (await VollyMemoryCache.GetAllOpportunities(_memoryCache, _context)) .SingleOrDefault(m => m.Id == id); if (opportunity == null) { return(NotFound()); } return(Ok(OpportunityView.FromOpportunity(opportunity))); }
public IActionResult Index() { List <OpportunityView> opportunityViews = _context.Opportunities .Include(o => o.Category) .Include(o => o.Community) .Include(o => o.Organization) .ThenInclude(o => o.Cause) .Include(o => o.Location) .Include(o => o.Occurrences) .ThenInclude(o => o.Applications) .AsNoTracking() .Where(o => !o.Approved) .Select(o => OpportunityView.FromOpportunity(o)) .ToList(); return(View(opportunityViews)); }