vendredi 30 octobre 2015

how to pass array in place of single object as input parameter in web api

public IHttpActionResult PosttblJudgeScores(tblJudgeScores tblJudgeScores)

here tblJudgeScores is single object which adding single judge score of single round .my intention is to pass all judge score for all round at same time

      [HttpPost]
    [Route("api/judgescore")]
    [ResponseType(typeof(tblJudgeScores))]
   public IHttpActionResult PosttblJudgeScores(tblJudgeScore enter code heretblJudgeScores)
    {
        if (!ModelState.IsValid)
        {
            return BadRequest(ModelState);
        }

        var checkscore = db.tblJudgeScores.Where(o => o.fightKey == tblJudgeScores.fightKey && o.roundNumber == tblJudgeScores.roundNumber && o.judgeKey == tblJudgeScores.judgeKey);
        if(checkscore.Count() == 0)
        {
            return Ok("Judge Already Scored for this round");
        }
        try
        {
            db.tblJudgeScores.Add(tblJudgeScores);
            db.SaveChanges();
        }
        catch (DbUpdateException)
        {
            if (tblJudgeScoresExists(tblJudgeScores.idx))
            {
                return Conflict();
            }
            else
            {
                throw;
            }
        }
        return Ok("Judge score inserted successfully");
    }




Aucun commentaire:

Enregistrer un commentaire