public KitBrick Create(KitBrick newKb)
        {
            int id = _repo.Create(newKb);

            newKb.Id = id;
            return(newKb);
        }
        internal int Create(KitBrick newKb)
        {
            string sql = @"
          INSERT INTO kitbricks
          (brickId, kitId, quantity)
          VALUES
          (@BrickId, @KitId, @Quantity);
          SELECT LAST_INSERT_ID();";

            return(_db.ExecuteScalar <int>(sql, newKb));
        }
 public ActionResult <KitBrick> Post([FromBody] KitBrick newKb)
 {
     try
     {
         return(Ok(_service.Create(newKb)));
     }
     catch (Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
Esempio n. 4
0
 public ActionResult <Brick> Post([FromBody] KitBrick newBrick)
 {
     try
     {
         return(Ok(_kbs.Create(newBrick)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public int Create(KitBrick newKb)
        {
            string sql = @"
        INSERT INTO kitbricks
        (kitId, brickId)
        VALUES
        (@KitId, @BrickId);
        SELECT LAST_INSERT_ID();";

            return(_db.ExecuteScalar <int>(sql, newKb));
        }
Esempio n. 6
0
        public KitBrick Create(KitBrick newKitBrick)
        {
            string sql = @"
      INSERT INTO kitBricks
      (kitId, brickId)
      VALUES
      (@KitId, @BrickId);
      SELECT LAST_INSERT_ID()";

            newKitBrick.Id = _db.ExecuteScalar <int>(sql, newKitBrick);
            return(newKitBrick);
        }
Esempio n. 7
0
 public KitBrick Create(KitBrick newKitBrick)
 {
     return(_repo.Create(newKitBrick));
 }