Esempio n. 1
0
        public async Task <IActionResult> Index()
        {
            List <Occurrence> occurrences = await _context.Occurrences
                                            .Include(o => o.Opportunity)
                                            .ToListAsync();

            return(View(occurrences.Select(OccurrenceTimeZoneConverter.ConvertFromUtc()).ToList()));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var occurrence = await _context.Occurrences.SingleOrDefaultAsync(m => m.Id == id);

            if (occurrence == null)
            {
                return(NotFound());
            }
            ViewData["OpportunityId"] = new SelectList(_context.Opportunities, "Id", "Name", occurrence.OpportunityId);
            return(View(OccurrenceTimeZoneConverter.ConvertFromUtc().Invoke(occurrence)));
        }
Esempio n. 3
0
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var occurrence = await _context.Occurrences
                             .Include(o => o.Opportunity)
                             .SingleOrDefaultAsync(m => m.Id == id);

            if (occurrence == null)
            {
                return(NotFound());
            }

            return(View(OccurrenceTimeZoneConverter.ConvertFromUtc().Invoke(occurrence)));
        }
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var opportunity = await _context.Opportunities
                              .Include(o => o.Category)
                              .Include(o => o.Organization)
                              .Include(o => o.Community)
                              .Include(o => o.OpportunityImages)
                              .Include(o => o.Occurrences)
                              .ThenInclude(occ => occ.Applications)
                              .AsNoTracking()
                              .SingleOrDefaultAsync(m => m.Id == id);

            if (opportunity == null)
            {
                return(NotFound());
            }

            List <Occurrence> occurrences = opportunity.Occurrences
                                            .Where(o => o.ApplicationDeadline > DateTime.Now && o.Openings > o.Applications.Count)
                                            .Select(occ => OccurrenceTimeZoneConverter.ConvertFromUtc().Invoke(occ))
                                            .ToList();

            ApplyModel applyModel = new ApplyModel()
            {
                OpportunityId = opportunity.Id,
                Opportunity   = opportunity,
                Occurrences   = new SelectList(occurrences, "Id", "StartTime")
            };

            ViewData["Message"] = Message;
            return(View(applyModel));
        }