public ActionResult <TestPlanet> Edit([FromBody] TestPlanet planet) { try { return(Ok(_tps.Unlock(planet))); } catch (Exception e) { return(BadRequest(e.Message)); } }
internal TestPlanet Unlock(TestPlanet planet) { var exists = _repo.GetById(planet.Id); if (exists == null) { throw new Exception("Invalid Id"); } else { var updatedPlanet = planet; updatedPlanet.isLocked = false; _repo.Unlock(updatedPlanet); return(updatedPlanet); } }
internal void Unlock(TestPlanet planet) { string sql = @"UPDATE testplanets SET planetName = @PlanetName, moneyNeeded = @MoneyNeeded, expiditionCost = @ExpiditionCost, resource1 = @Resource1, resource2 = @Resource2, resource3 = @Resource3, resource4 = @Resource4, planetImg = @planetImg, isLocked = @isLocked WHERE id = @Id;"; _db.Execute(sql, planet); }