public IHttpActionResult postRequest(ScorerMatchViewModel model) { db.openConnection(); DataTable dt = null; try { if (model.actionUser == "save_all_by_match") { paramName = new string[] { "pIdCamp", "pIdJogo", "pIdsGoleadorHome", "pQtGolsGoleadorHome", "pIdsGoleadorAway", "pQtGolsGoleadorAway" }; paramValue = new string[] { Convert.ToString(model.championshipID), Convert.ToString(model.matchID), model.loadScorersIDHome, model.loadScorersGoalsHome, model.loadScorersIDAway, model.loadScorersGoalsAway }; dt = db.executePROC("spAddLoadGoleadorJogo", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "delete_all_by_match") { paramName = new string[] { "pIdJogo" }; paramValue = new string[] { Convert.ToString(model.matchID) }; dt = db.executePROC("spDeleteAllGoleadorJogo", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "errorScorerMatch_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; } }
public IHttpActionResult GetAllByMatch(string id) { ScorerMatchViewModel mainModel = new ScorerMatchViewModel(); DataTable dt = null; db.openConnection(); try { string[] arrayParam = id.Split(Convert.ToChar("|")); paramName = new string[] { "pIdCamp", "pIdJogo" }; paramValue = new string[] { arrayParam[0], arrayParam[1] }; dt = db.executePROC("spGetAllGoleadoresByJogo", paramName, paramValue); if (dt.Rows.Count > 0) { mainModel.listOfScorerMatch = setUpListDetailsScorers(dt); } mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } catch (Exception ex) { mainModel.listOfScorerMatch = new List <ScorerMatchDetails>(); mainModel.returnMessage = "errorGetScorerMatch_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } finally { db.closeConnection(); dt = null; mainModel = null; } }