public JObject ManageAgentScoreCards(String connection, UDC.AgentScoreCard scoresObj) { try { Press3.DataAccessLayer.Scorecards scoreCardObj = new Press3.DataAccessLayer.Scorecards(connection); JArray scoresArray = JArray.Parse(scoresObj.Scores); DataTable scoresDt = new DataTable(); scoresDt.Columns.Add("QuestionId", typeof(int)); scoresDt.Columns.Add("Answer", typeof(int)); for (int i = 0; i <= scoresArray.Count - 1; i++) { scoresDt.Rows.Add(scoresArray[i].SelectToken("QuestionId").ToString(), scoresArray[i].SelectToken("Answer").ToString()); } DataSet ds = scoreCardObj.ManageAgentScoreCards(scoresObj, scoresDt); if (ds == null) { _helper.CreateProperty(UDC.Label.MESSAGE, "No data returned from database"); _helper.CreateProperty(UDC.Label.SUCCESS, false); } else { _helper.ParseDataSet(ds); } } catch (Exception ex) { Logger.Error("Exception In BAL.ManageAgentScoreCards " + ex.ToString()); } return(_helper.GetResponse()); }
public JObject ManageAgentScoreCards(HttpContext context) { JObject resultObj = new JObject(); try { Press3.BusinessRulesLayer.Manager managerObj = new Press3.BusinessRulesLayer.Manager(); UDC.AgentScoreCard scoresObj = new UDC.AgentScoreCard(); scoresObj.Id = (context.Request["agentScoreCardId"] != null && context.Request["agentScoreCardId"] != "") ? Convert.ToInt32(context.Request["agentScoreCardId"]) : 0; scoresObj.AccountId = accountId; scoresObj.AgentId = Convert.ToInt32(context.Request["agentId"]); scoresObj.CallId = Convert.ToInt32(context.Request["callId"]); scoresObj.ScoreCardId = Convert.ToInt32(context.Request["scoreCardId"]); scoresObj.ScoredBy = agentId; scoresObj.TotalScore = Convert.ToDouble(context.Request["totalScore"]); scoresObj.OutOfScore = Convert.ToDouble(context.Request["outOfScore"]); scoresObj.Rating = Convert.ToDouble(context.Request["rating"]); scoresObj.Comments = context.Request["comments"]; scoresObj.Scores = context.Request["scores"]; resultObj = managerObj.ManageAgentScoreCards(MyConfig.MyConnectionString, scoresObj); } catch (Exception ex) { Logger.Error(ex.ToString()); throw ex; } return(resultObj); }
public DataSet ManageAgentScoreCards(UDC.AgentScoreCard scoresObj, DataTable scores) { _sqlCommand = new SqlCommand(); _dataSet = new DataSet(); try { _sqlCommand.CommandText = "ManageAgentScoreCards"; _sqlCommand.CommandType = CommandType.StoredProcedure; _sqlCommand.Connection = Connection; _sqlCommand.Parameters.Add("@AgentScoreCardId", SqlDbType.Int).Value = scoresObj.Id; _sqlCommand.Parameters.Add("@AccountId", SqlDbType.Int).Value = scoresObj.AccountId; _sqlCommand.Parameters.Add("@AgentId", SqlDbType.Int).Value = scoresObj.AgentId; _sqlCommand.Parameters.Add("@CallId", SqlDbType.Int).Value = scoresObj.CallId; _sqlCommand.Parameters.Add("@ScoreCardId", SqlDbType.Int).Value = scoresObj.ScoreCardId; _sqlCommand.Parameters.Add("@ScoredBy", SqlDbType.Int).Value = scoresObj.ScoredBy; _sqlCommand.Parameters.Add("@Scores", SqlDbType.Structured).Value = scores; _sqlCommand.Parameters.Add("@TotalScore", SqlDbType.Float).Value = scoresObj.TotalScore; _sqlCommand.Parameters.Add("@OutOfScore", SqlDbType.Float).Value = scoresObj.OutOfScore; _sqlCommand.Parameters.Add("@Rating", SqlDbType.Float).Value = scoresObj.Rating; _sqlCommand.Parameters.Add("@Comments", SqlDbType.NVarChar, -1).Value = scoresObj.Comments; _sqlCommand.Parameters.Add("@IsDraft", SqlDbType.Bit).Value = scoresObj.IsDraft; _sqlCommand.Parameters.Add("@Message", SqlDbType.VarChar, 500).Direction = ParameterDirection.Output; _sqlCommand.Parameters.Add("@Success", SqlDbType.Bit).Direction = ParameterDirection.Output; Connection.Open(); _sqlCommand.ExecuteNonQuery(); Connection.Close(); _dataSet.Tables.Add(_helper.ConvertOutputParametersToDataTable(_sqlCommand.Parameters)); } catch (Exception ex) { Utilities.Logger.Error(ex.ToString()); } finally { _sqlCommand = null; Connection.Close(); } return(_dataSet); }