public async Task <IActionResult> PutNonResidentialPremise(int id, NonResidentialPremiseRequest nonResidentialPremiseRequest) { NonResidentialPremise nonResidentialPremise = nonResidentialPremiseRequest.NonResidentialPremise; string token = nonResidentialPremiseRequest.token; if (!Security.TokenIsValid(token)) { return(StatusCode(401)); } if (id != nonResidentialPremise.Id) { return(BadRequest()); } _context.Entry(nonResidentialPremise).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NonResidentialPremiseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <NonResidentialPremise> > PostNonResidentialPremise(NonResidentialPremiseRequest nonResidentialPremiseRequest) { NonResidentialPremise nonResidentialPremise = nonResidentialPremiseRequest.NonResidentialPremise; string token = nonResidentialPremiseRequest.token; if (!Security.TokenIsValid(token)) { return(StatusCode(401)); } _context.NonResidentialPremises.Add(nonResidentialPremise); await _context.SaveChangesAsync(); return(CreatedAtAction("GetNonResidentialPremise", new { id = nonResidentialPremise.Id }, nonResidentialPremise)); }