public IActionResult EditScorecardDetails(ScorecardModel scorecard) { _database.Scorecards.Update(scorecard); _database.SaveChanges(); return(RedirectToAction("ScorecardDetails", new { id = scorecard.ID })); }
public IActionResult CreateScorecard(ScorecardModel scorecard) { _database.Scorecards.Add(scorecard); _database.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult CreateScorecard() { var scorecard = new ScorecardModel { DefaultTestValue = 1 }; return(View(scorecard)); }
public ActionResult Results(Models.Results model) { UserTableAdapter UserTA = new UserTableAdapter(); ResultTableAdapter ResultTA = new ResultTableAdapter(); dsScorecard ScorecardDataset = new dsScorecard(); ScorecardTableAdapter ScorecardTA = new ScorecardTableAdapter(); ScorecardTA.Fill(ScorecardDataset.Scorecard, model.ScorecardID); model.ScorecardName = ((dsScorecard.ScorecardRow)ScorecardDataset.Scorecard.Rows[0]).ScorecardName; ResultTA.Fill(ScorecardDataset.Result, Convert.ToInt32(model.ScorecardID), null); UserTA.Fill(ScorecardDataset.User); model.ListOfResults = new Dictionary <int, ScorecardModel>(); foreach (dsScorecard.ResultRow Row in ScorecardDataset.Result) { dsScorecard.UserRow UserRow = ScorecardDataset.User.FindByUserID(Row.AgentID); dsScorecard.UserRow ScorerRow = ScorecardDataset.User.FindByUserID(Row.ScorerID); ScorecardModel Scorecard = new ScorecardModel { score = Row.Score, datescored = Row.DateScored, agentscored = new User { firstname = UserRow.FirstName, surname = UserRow.Surname }, scoredby = new User { firstname = ScorerRow.FirstName, surname = ScorerRow.Surname } }; model.ListOfResults.Add(Row.ResultID, Scorecard); } return(View(model)); }
public ActionResult Score(ScorecardModel model, string submit) { dsScorecard ScorecardDataset = new dsScorecard(); ScorecardTableAdapter ScorecardTA = new ScorecardTableAdapter(); ScorecardTA.Fill(ScorecardDataset.Scorecard, model.scorecardid); dsScorecard.ScorecardRow ScoreCardRow = ScorecardDataset.Scorecard.FindByScorecardID(model.scorecardid); model.scorecardname = ScoreCardRow.ScorecardName; if (submit == "Load") { RecordingSelectCommandTableAdapter RecordingTA = new RecordingSelectCommandTableAdapter(); RecordingTA.Fill(ScorecardDataset.RecordingSelectCommand, model.callreference.ToString()); model.Callrecordinglist = new List <SelectListItem>(); foreach (dsScorecard.RecordingSelectCommandRow row in ScorecardDataset.RecordingSelectCommand.Rows) { SelectListItem item = new SelectListItem(); item.Text = row.Description; item.Value = row.CallDate.ToString("ddMMyyyy") + "\\" + row.FileName; model.Callrecordinglist.Add(item); } } if (submit == "Load Call") { string recordingpath = ScorecardApplication.Properties.Settings.Default.CallRecordingPath + model.recording; model.recordingfilename = recordingpath.Replace(".vox", ".mp3"); ScorecardItemGroupTableAdapter SCGroupTA = new ScorecardItemGroupTableAdapter(); SCGroupTA.Fill(ScorecardDataset.ScorecardItemGroup, model.scorecardid); ScorecardItemTableAdapter SCItemTA = new ScorecardItemTableAdapter(); if (ScorecardDataset.ScorecardItemGroup.Rows.Count > 0) { model.scorecardgroups = new List <ScorecardGroup>(); } foreach (dsScorecard.ScorecardItemGroupRow GroupRow in ScorecardDataset.ScorecardItemGroup.Rows) { ScorecardGroup NewGroup = new ScorecardGroup() { groupid = GroupRow.ScorecardItemGroupID, groupdescription = GroupRow.Description, groupname = GroupRow.GroupName, pasmark = GroupRow.PassScore }; SCItemTA.Fill(ScorecardDataset.ScorecardItem, model.scorecardid, GroupRow.ScorecardItemGroupID); if (ScorecardDataset.ScorecardItem.Rows.Count > 0) { NewGroup.scorecarditems = new List <ScorecardItem>(); } foreach (dsScorecard.ScorecardItemRow ItemRow in ScorecardDataset.ScorecardItem.Rows) { ScorecardItem NewItem = new ScorecardItem(); NewItem.autofail = ItemRow.AutoFail.ToString(); String[] PossibleAnswerArray = ItemRow.PossibleAnswers.Split("|".ToCharArray()); NewItem.possibleanswerslist = new List <SelectListItem>(); foreach (String possibleanswer in PossibleAnswerArray) { SelectListItem SelectItem = new SelectListItem { Text = possibleanswer, Value = possibleanswer }; NewItem.possibleanswerslist.Add(SelectItem); } ; NewItem.question = ItemRow.Question; NewItem.questiontype = ItemRow.QuestionType; NewItem.itemid = ItemRow.ScorecardItemID; NewGroup.scorecarditems.Add(NewItem); } model.scorecardgroups.Add(NewGroup); } } if (submit == "Save Scorecard") { ResultTableAdapter ResultTA = new ResultTableAdapter(); ResultItemTableAdapter ResultItemTA = new ResultItemTableAdapter(); ResultGroupTableAdapter ResultGroupTA = new ResultGroupTableAdapter(); UserTableAdapter UserTA = new UserTableAdapter(); UserTA.Fill(ScorecardDataset.User); int ScorerID = 0; foreach (dsScorecard.UserRow row in ScorecardDataset.User) { if (row.Username.ToLower() == User.Identity.Name.ToLower()) { ScorerID = row.UserID; } } ScorecardItemGroupTableAdapter SCGroupTA = new ScorecardItemGroupTableAdapter(); SCGroupTA.Fill(ScorecardDataset.ScorecardItemGroup, model.scorecardid); ScorecardItemTableAdapter SCItemTA = new ScorecardItemTableAdapter(); SCItemTA.Fill(ScorecardDataset.ScorecardItem, model.scorecardid, null); model.score = 0; bool AutoFail = false; foreach (ScorecardGroup Group in model.scorecardgroups) { Group.score = 0; foreach (ScorecardItem Item in Group.scorecarditems) { dsScorecard.ScorecardItemRow ItemRow = ScorecardDataset.ScorecardItem.FindByScorecardItemID(Item.itemid); if (Item.answer.ToLower() == ItemRow.Answer.ToLower()) { Item.score = ItemRow.ScoreModifier; Group.score += ItemRow.ScoreModifier; model.score += ItemRow.ScoreModifier; } else { Item.score = 0; if (Item.autofail.ToLower() == "true") { AutoFail = true; } } } } if (AutoFail) { model.score = 0; } // Save Results int ResultID = Convert.ToInt32(ResultTA.ResultInsertCommand(model.agentscored.userid, ScorerID, model.scorecardid, DateTime.Now, model.callreference, model.score, model.comment)); foreach (ScorecardGroup Group in model.scorecardgroups) { int GroupID = 0; GroupID = Convert.ToInt32(ResultGroupTA.ResultGroupInsertCommand(ResultID, Group.groupid, Group.comment, Group.score)); foreach (ScorecardItem Item in Group.scorecarditems) { ResultItemTA.ResultItemInsertCommand(ResultID, Item.itemid, Item.answer, Item.score, Item.comment, GroupID); } } return(Redirect("/home/index")); } return(View(model)); }
public ActionResult ScorecardResult(int ResultID) { ScorecardModel model = new ScorecardModel(); dsScorecard ScorecardDataset = new dsScorecard(); ResultTableAdapter ResultTA = new ResultTableAdapter(); ResultGroupTableAdapter ResultGroupTA = new ResultGroupTableAdapter(); ResultItemTableAdapter ResultItemTA = new ResultItemTableAdapter(); ScorecardTableAdapter ScorecardTA = new ScorecardTableAdapter(); ScorecardItemGroupTableAdapter ScorecardGroupTA = new ScorecardItemGroupTableAdapter(); ScorecardItemTableAdapter ScorecardItemTA = new ScorecardItemTableAdapter(); ResultTA.Fill(ScorecardDataset.Result, null, ResultID); ResultGroupTA.Fill(ScorecardDataset.ResultGroup, ResultID); ResultItemTA.Fill(ScorecardDataset.ResultItem, ResultID); dsScorecard.ResultRow ResultRow = ((dsScorecard.ResultRow)ScorecardDataset.Result.Rows[0]); UserTableAdapter UserTA = new UserTableAdapter(); UserTA.Fill(ScorecardDataset.User); dsScorecard.UserRow AgentScoredRow = ScorecardDataset.User.FindByUserID(ResultRow.AgentID); dsScorecard.UserRow ScoredByRow = ScorecardDataset.User.FindByUserID(ResultRow.ScorerID); ScorecardTA.Fill(ScorecardDataset.Scorecard, ResultRow.ScorecardID); ScorecardGroupTA.Fill(ScorecardDataset.ScorecardItemGroup, ResultRow.ScorecardID); dsScorecard.ScorecardRow ScorecardRow = ((dsScorecard.ScorecardRow)ScorecardDataset.Scorecard.Rows[0]); model.scorecardname = ScorecardRow.ScorecardName; model.scorecarddescription = ScorecardRow.ScorecardDescription; model.scorecardgroups = new List <ScorecardGroup>(); model.agentscored = new User { emailaddress = AgentScoredRow.EmailAddress, firstname = AgentScoredRow.FirstName, surname = AgentScoredRow.Surname }; model.scoredby = new User { emailaddress = ScoredByRow.EmailAddress, firstname = ScoredByRow.FirstName, surname = ScoredByRow.Surname }; model.comment = ResultRow.Comment; model.datescored = ResultRow.DateScored; model.callreference = ResultRow.CallReference; model.score = ResultRow.Score; foreach (dsScorecard.ScorecardItemGroupRow GroupRow in ScorecardDataset.ScorecardItemGroup) { DataRow[] ResultGroupRows = ScorecardDataset.ResultGroup.Select("ScorecardItemGroupID=" + GroupRow.ScorecardItemGroupID.ToString()); ScorecardGroup GroupItem = new ScorecardGroup { groupname = GroupRow.GroupName, pasmark = GroupRow.PassScore, groupdescription = GroupRow.Description, comment = ((dsScorecard.ResultGroupRow)ResultGroupRows[0]).Comment, score = ((dsScorecard.ResultGroupRow)ResultGroupRows[0]).Score }; GroupItem.scorecarditems = new List <ScorecardItem>(); ScorecardDataset.ScorecardItem.Clear(); ScorecardItemTA.Fill(ScorecardDataset.ScorecardItem, ResultRow.ScorecardID, GroupRow.ScorecardItemGroupID); foreach (dsScorecard.ScorecardItemRow ItemRow in ScorecardDataset.ScorecardItem) { DataRow[] ResultItemRows = ScorecardDataset.ResultItem.Select("QuestionID=" + ItemRow.ScorecardItemID.ToString()); ScorecardItem Item = new ScorecardItem { question = ItemRow.Question, autofail = ItemRow.AutoFail.ToString(), questiontype = ItemRow.QuestionType, scoremodifier = ItemRow.ScoreModifier, answer = ((dsScorecard.ResultItemRow)ResultItemRows[0]).Answer, comment = ((dsScorecard.ResultItemRow)ResultItemRows[0]).Comment, score = ((dsScorecard.ResultItemRow)ResultItemRows[0]).Score }; GroupItem.scorecarditems.Add(Item); } model.scorecardgroups.Add(GroupItem); } return(View(model)); }