public async Task <IActionResult> PutLiveTourZone(int id, LiveTourZone liveTourZone) { int idAgency = await _userService.GetAuthorizedAgencyId(this.User); if (id != liveTourZone.Id) { return(BadRequest()); } if (liveTourZone.AgencyID != idAgency) { return(BadRequest(new { message = "resource is not yours" })); } _context.Entry(liveTourZone).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LiveTourZoneExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <LiveTourZone> > PostLiveTourZone(LiveTourZone liveTourZone) { int idAgency = await _userService.GetAuthorizedAgencyId(this.User); liveTourZone.AgencyID = idAgency; _context.LiveTourZone.Add(liveTourZone); await _context.SaveChangesAsync(); return(CreatedAtAction("GetLiveTourZone", new { id = liveTourZone.Id }, liveTourZone)); }