internal void Create(KnightQuest newData) { KnightQuest exists = _repo.Find(newData); if (exists != null) { throw new Exception("Knight already on Quest"); } _repo.Create(newData); }
public ActionResult <String> Edit([FromBody] KnightQuest kqs) { try { return(Ok(_kq.Delete(kqs))); } catch (Exception e) { return(BadRequest(e.Message)); } }
internal string Delete(KnightQuest kqs) { KnightQuest exists = _repo.Find(kqs); if (exists == null) { throw new Exception("Invalid ID combination"); } _repo.Delete(exists.Id); return("Successfully Deleted"); }
public ActionResult <String> Create([FromBody] KnightQuest newData) { try { _kq.Create(newData); return(Ok("Success")); } catch (Exception e) { return(BadRequest(e.Message)); } }
internal KnightQuest Create(KnightQuest newData) { string sql = @" INSERT INTO knightsquests (knightId, questId) VALUES (@KnightId, @QuestId); SELECT LAST_INSERT_ID(); "; int id = _db.ExecuteScalar <int>(sql, newData); newData.Id = id; return(newData); }
internal KnightQuest Find(KnightQuest kqs) { string sql = "SELECT * FROM knightsquests WHERE (questId = @QuestId AND knightId = @KnightId)"; return(_db.QueryFirstOrDefault(sql, kqs)); }