public async Task <IActionResult> PutLandPlot(int id, LandPlotRequest landPlotRequest) { LandPlot landPlot = landPlotRequest.LandPlot; string token = landPlotRequest.token; if (!Security.TokenIsValid(token)) { return(StatusCode(401)); } if (id != landPlot.Id) { return(BadRequest()); } _context.Entry(landPlot).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LandPlotExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <LandPlot> > PostLandPlot(LandPlotRequest landPlotRequest) { LandPlot landPlot = landPlotRequest.LandPlot; string token = landPlotRequest.token; if (!Security.TokenIsValid(token)) { return(StatusCode(401)); } _context.LandPlots.Add(landPlot); await _context.SaveChangesAsync(); return(CreatedAtAction("GetLandPlot", new { id = landPlot.Id }, landPlot)); }