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