public JObject ViewScorecards(string connectionString, int accountId, int scorecardId) { try { if (accountId == 0) { _helper.CreateProperty(UDC.Label.SUCCESS, false); _helper.CreateProperty(UDC.Label.MESSAGE, "AccountId is mandatory"); } else { DataAccessLayer.Scorecards scoreObj = new DataAccessLayer.Scorecards(connectionString); System.Data.DataSet ds = scoreObj.ViewScorecards(accountId, scorecardId); if (ds == null) { _helper.CreateProperty(UDC.Label.SUCCESS, false); _helper.CreateProperty(UDC.Label.MESSAGE, scoreObj.ErrorMessage); } else { _helper.ParseDataSet(ds); } } } catch (Exception e) { Utilities.Logger.Error(e.ToString()); _helper.InitializeResponseVariables(); _helper.CreateProperty(UDC.Label.SUCCESS, false); _helper.CreateProperty(UDC.Label.MESSAGE, e.Message); } return(_helper.GetResponse()); }
public JObject Create(string connectionString, string scorecard, int accountId, int agentId) { try { JObject jsonObj = default(JObject); jsonObj = new JObject(); jsonObj = JObject.Parse(scorecard); string ScorecardTitle = jsonObj.SelectToken("ScorecardTitle").ToString(); int skillGroupId = Convert.ToInt32(jsonObj.SelectToken("SkillGroupId").ToString()); DataTable sectionsTable = new DataTable(); sectionsTable.Columns.Add("Id", typeof(int)); sectionsTable.Columns.Add("Name", typeof(string)); DataTable questionsTable = new DataTable(); questionsTable.Columns.Add("Question", typeof(string)); questionsTable.Columns.Add("PointsForYes", typeof(string)); questionsTable.Columns.Add("SectionId", typeof(int)); JToken jUser = jsonObj["Sections"]; int count = jUser.Count(); int sectionId = 0; for (int i = 0; i < count; i++) { sectionId = i + 1; sectionsTable.Rows.Add(i + 1, jUser[i].SelectToken("sectionTitle").ToString()); JArray items = (JArray)jUser[i].SelectToken("Questions"); int questionsCount = items.Count(); for (int j = 0; j < questionsCount; j++) { string Question = items[j].SelectToken("Question").ToString(); string PointsForYes = items[j].SelectToken("PointsForYes").ToString(); questionsTable.Rows.Add(Question, PointsForYes, sectionId); } } DataAccessLayer.Scorecards ScoreObj = new DataAccessLayer.Scorecards(connectionString); System.Data.DataSet ds = ScoreObj.Create(ScorecardTitle, skillGroupId, sectionsTable, questionsTable, accountId, agentId); if (ds.IsNull()) { _helper.CreateProperty(UDC.Label.SUCCESS, false); _helper.CreateProperty(UDC.Label.MESSAGE, ScoreObj.ErrorMessage); } else { _helper.ParseDataSet(ds); } } catch (Exception e) { Utilities.Logger.Error(e.ToString()); _helper.InitializeResponseVariables(); _helper.CreateProperty(UDC.Label.SUCCESS, false); _helper.CreateProperty(UDC.Label.MESSAGE, e.Message); } return(_helper.GetResponse()); }