public ActionResult EditUser(int?UserID) { Models.User model = new Models.User(); dsScorecard ScorecardDataset = new dsScorecard(); UserLevelTableAdapter UserLevelTA = new UserLevelTableAdapter(); UserLevelTA.Fill(ScorecardDataset.UserLevel); model.UserLevelList = new List <SelectListItem>(); foreach (dsScorecard.UserLevelRow Row in ScorecardDataset.UserLevel) { model.UserLevelList.Add(new SelectListItem { Text = Row.Description, Value = Row.UserLevelID.ToString() }); } if (UserID != null) { UserTableAdapter UserTA = new UserTableAdapter(); UserTA.Fill(ScorecardDataset.User); dsScorecard.UserRow UserRow = ScorecardDataset.User.FindByUserID(UserID.Value); dsScorecard.UserLevelRow UserLevelRow = ScorecardDataset.UserLevel.FindByUserLevelID(UserRow.UserLevelID); String[] PagePermissions = UserLevelRow.PagePermissions.Split(Convert.ToChar(",")); UserLevel UserLevelModel = new UserLevel { decription = UserLevelRow.Description, userlevelid = UserLevelRow.UserLevelID, pagepermissions = new List <String>() }; foreach (String Item in PagePermissions) { UserLevelModel.pagepermissions.Add(Item); } model.emailaddress = UserRow.EmailAddress; model.firstname = UserRow.FirstName; model.surname = UserRow.Surname; model.userid = UserRow.UserID; model.userlevel = UserLevelModel; model.username = UserRow.Username; } return(View(model)); }
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 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)); }