Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,StartTime,EndTime,ApplicationDeadline,Openings,OpportunityId")] Occurrence occurrence)
        {
            if (id != occurrence.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(OccurrenceTimeZoneConverter.ConvertToUtc().Invoke(occurrence));
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OccurrenceExists(occurrence.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OpportunityId"] = new SelectList(_context.Opportunities, "Id", "Name", occurrence.OpportunityId);
            return(View(occurrence));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,StartTime,EndTime,ApplicationDeadline,Openings,OpportunityId")] Occurrence occurrence)
        {
            if (ModelState.IsValid)
            {
                _context.Add(OccurrenceTimeZoneConverter.ConvertToUtc().Invoke(occurrence));
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OpportunityId"] = new SelectList(_context.Opportunities, "Id", "Name", occurrence.OpportunityId);
            return(View(occurrence));
        }