// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var advertisement = new job4everyone.Models.Advertisement() { Name = Advertisement.Name, Description = Advertisement.Description, Active = Advertisement.Active, JobPosition = Advertisement.JobPosition }; try { service.UpdateAdvertisement(Advertisement.Id, advertisement); } catch (DbUpdateConcurrencyException) { if (!AdvertisementExists(Advertisement.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Advertisement = await _context.Advertisements .Include(a => a.Employer) .Include(a => a.JobPosition).FirstOrDefaultAsync(m => m.Id == id); if (Advertisement == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Advertisement = await _context.Advertisements .Include(a => a.JobPosition).FirstOrDefaultAsync(m => m.Id == id); if (Advertisement == null) { return(NotFound()); } ViewData["JobPositionId"] = new SelectList(_context.JobPositions, "Id", "Name"); return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Advertisement = await _context.Advertisements.FindAsync(id); if (Advertisement != null) { _context.Advertisements.Remove(Advertisement); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }