protected void Batches_SelectedIndexChanged(object sender, EventArgs e) { //Bind Active Batch Content ListBox var selectedBatch = long.Parse(Batches.SelectedValue); var selectedIndex = Batches.SelectedIndex; var batch = _db.T_Batch.FirstOrDefault(s => s.Id == selectedBatch); List <BatchContentDropDownModel> activeContent = _db.T_BatchSet.Where(s => s.BatchId == selectedBatch).Select(a => new BatchContentDropDownModel { ID = a.CandidateId.Value, Name = _db.T_Candidate.FirstOrDefault(s => s.Id == a.CandidateId).Code + " - " + _db.T_Candidate.FirstOrDefault(s => s.Id == a.CandidateId).FirstName + " " + _db.T_Candidate.FirstOrDefault(s => s.Id == a.CandidateId).LastName }).ToList(); if (activeContent.Count > 0) { ActiveContentList.DataSource = activeContent; ActiveContentList.DataBind(); SendInvite.Enabled = true; } else { activeContent = new List <BatchContentDropDownModel>(); activeContent.Add(new BatchContentDropDownModel { ID = 0, Name = "---" + batch.Name + " is Empty---" }); ActiveContentList.DataSource = activeContent; ActiveContentList.DataBind(); SendInvite.Enabled = false; } }
public IEnumerable <ActiveContentList> PostCleanup([FromHeader] string AppCode, [FromHeader] string CompanyCode) { //Containts Cleanup Instruction for bot ClientContent and ClientSubContent string CurrentContentList = ""; string CurrentSubContentList = ""; string UpperCaseCC = CompanyCode.Trim().ToUpper(); CreatorEntities db = new CreatorEntities(); List <ActiveContentList> CleanupList = new List <ActiveContentList>(); //ClientContent List <ClientContent> Listc = db.ClientContent.Where(c => c.ClientSubMenus.ClientMenus.ClientApps.Clients.Code == UpperCaseCC) .Where(ca => ca.ClientSubMenus.ClientMenus.ClientApps.Apps.AppCode == AppCode) .ToList(); foreach (ClientContent c in Listc) { CurrentContentList = CurrentContentList + c.ID + ","; } if (Listc.Count > 0) { CurrentContentList = "(" + CurrentContentList.Substring(0, CurrentContentList.Length - 1) + ")"; } //ClientSubContent List <ClientSubContent> Listsc = db.ClientSubContent.Where(c => c.ClientSubSubMenus.ClientSubMenuMenus.ClientMenus.ClientApps.Clients.Code == UpperCaseCC) .Where(ca => ca.ClientSubSubMenus.ClientSubMenuMenus.ClientMenus.ClientApps.Apps.AppCode == AppCode) .ToList(); foreach (ClientSubContent sc in Listsc) { CurrentSubContentList = CurrentSubContentList + sc.ClientSubContentID + ","; } if (Listsc.Count > 0) { CurrentSubContentList = "(" + CurrentSubContentList.Substring(0, CurrentSubContentList.Length - 1) + ")"; } ActiveContentList list = new ActiveContentList(); list.Content = CurrentContentList; list.SubContent = CurrentSubContentList; CleanupList.Add(list); return(CleanupList); }
protected void Button2_Click(object sender, EventArgs e) { try{ var selectedBatch = long.Parse(Batches.SelectedValue); var selectedIndex = Batches.SelectedIndex; var batch = _db.T_Batch.FirstOrDefault(s => s.Id == selectedBatch); int[] selectedCandidates = ActiveContentList.GetSelectedIndices(); var contentIds = new List <int>(); var cids = selectedCandidates.Select(i => int.Parse(ActiveContentList.Items[i].Value)).ToList(); // int count = cids.Count; foreach (int x in cids) { if (x == 0) { } else { contentIds.Add(x); } } foreach (int x in contentIds) { var entry = _db.T_BatchSet.FirstOrDefault(s => s.BatchId == batch.Id && s.CandidateId == x); if (entry != null) { _db.T_BatchSet.Remove(entry); } } _db.SaveChanges(); Session["ToBeSelected"] = selectedIndex; Response.Redirect("AddCandidateToBatch.aspx", false); } catch (Exception ex) { ErecruitHelper.SetErrorData(ex, Session); Response.Redirect("ErrorPage.aspx", false); } }
protected void Page_Load(object sender, EventArgs e) { string currentPageFileName = new FileInfo(this.Request.Url.AbsolutePath).Name; var PermMgr = new PermissionManager(Session); if (PermMgr.IsAdmin || PermMgr.CanManageTestBatches) { if (!IsPostBack) { //Bind Active Batch DropDownList var activeBatches = _db.T_Batch.Where(s => (s.BatchType == ErecruitHelper.BatchType.Multiple.ToString() || s.BatchType == null) && s.IsActive.Value == true).ToList(); Batches.DataSource = activeBatches; if (Session["ToBeSelected"] != null) { Batches.SelectedIndex = int.Parse(Session["ToBeSelected"].ToString()); } Batches.DataBind(); //Bind Active Candidate ListBox var cands = _db.T_Candidate.Where(s => s.ApprovalStatus == ErecruitHelper.ApprovalStatus.APPROVED.ToString() && s.IsActive.Value == true).Select(a => new CandidateDropDownModel { ID = a.Id, Name = a.Code + " - " + a.LastName + " " + a.FirstName }).ToList(); ActiveCandidateList.DataSource = cands; ActiveCandidateList.DataBind(); //Bind Active Batch Content ListBox var x = string.IsNullOrEmpty(Batches.SelectedValue) ? "0" : Batches.SelectedValue; var selectedBatch = long.Parse(x); var batch = new T_Batch(); if (selectedBatch == 0) { batch = new T_Batch { Id = 0, Name = "No Active batch." }; } else { batch = _db.T_Batch.FirstOrDefault(s => s.Id == selectedBatch); } List <BatchContentDropDownModel> activeContent = _db.T_BatchSet.Where(s => s.BatchId == selectedBatch).Select(a => new BatchContentDropDownModel { ID = a.CandidateId.Value, Name = _db.T_Candidate.FirstOrDefault(s => s.Id == a.CandidateId).Code + " - " + _db.T_Candidate.FirstOrDefault(s => s.Id == a.CandidateId).FirstName + " " + _db.T_Candidate.FirstOrDefault(s => s.Id == a.CandidateId).LastName }).ToList(); if (activeContent.Count > 0) { ActiveContentList.DataSource = activeContent; ActiveContentList.DataBind(); SendInvite.Enabled = true; } else { activeContent = new List <BatchContentDropDownModel>(); activeContent.Add(new BatchContentDropDownModel { ID = 0, Name = "---" + batch.Name + " is Empty---" }); ActiveContentList.DataSource = activeContent; ActiveContentList.DataBind(); SendInvite.Enabled = false; } //Bind DropDownList1 ListBox var cs = _db.T_Candidate.Where(s => s.ApprovalStatus == ErecruitHelper.ApprovalStatus.APPROVED.ToString() && s.IsActive.Value == true).Select(a => new CandidateDropDownModel { ID = a.Id, Name = a.Code + " - " + a.LastName + " " + a.FirstName }).ToList(); DropDownList1.DataSource = cs; DropDownList1.DataBind(); } } else { Response.Redirect("NoPermission.aspx", false); } }