public async Task <IActionResult> PutLiveTour(int id, LiveTour liveTour) { int idAgency = await _userService.GetAuthorizedAgencyId(this.User); if (id != liveTour.Id) { return(BadRequest()); } if (liveTour.AgencyID != idAgency) { return(BadRequest(new { message = "resource is not yours" })); } _context.Entry(liveTour).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LiveTourExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <LiveTour> > PostLiveTour(LiveTour liveTour) { int idAgency = await _userService.GetAuthorizedAgencyId(this.User); liveTour.AgencyID = idAgency; _context.LiveTours.Add(liveTour); await _context.SaveChangesAsync(); return(CreatedAtAction("GetLiveTour", new { id = liveTour.Id }, liveTour)); }