public async Task <IActionResult> Edit(int id, [Bind("Id,ClientId,ConsultantId")] ConsultationBooking consultationBooking) { if (id != consultationBooking.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(consultationBooking); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConsultationBookingExists(consultationBooking.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ClientId"] = new SelectList(_context.Client, "Id", "Id", consultationBooking.ClientId); ViewData["ConsultantId"] = new SelectList(_context.Consultant, "Id", "Id", consultationBooking.ConsultantId); return(View(consultationBooking)); }
public async Task <IActionResult> Create([Bind("Id,ClientId,ConsultantId")] ConsultationBooking consultationBooking) { if (ModelState.IsValid) { _context.Add(consultationBooking); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ClientId"] = new SelectList(_context.Client, "Id", "Id", consultationBooking.ClientId); ViewData["ConsultantId"] = new SelectList(_context.Consultant, "Id", "Id", consultationBooking.ConsultantId); return(View(consultationBooking)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } ConsultationBooking = await _context.ConsultationBooking .Include(c => c.Client) .Include(c => c.Consultant).FirstOrDefaultAsync(m => m.Id == id); if (ConsultationBooking == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ConsultationBooking = await _context.ConsultationBooking.FindAsync(id); if (ConsultationBooking != null) { _context.ConsultationBooking.Remove(ConsultationBooking); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } ConsultationBooking = await _context.ConsultationBooking .Include(c => c.Client) .Include(c => c.Consultant).FirstOrDefaultAsync(m => m.Id == id); if (ConsultationBooking == null) { return(NotFound()); } ViewData["ClientId"] = new SelectList(_context.Client, "Id", "Name"); ViewData["ConsultantId"] = new SelectList(_context.Consultant, "Id", "Name"); return(Page()); }