public JsonResult GetRoleList(UserTypeUserList selectedUser) { //string orgid = Session["OrgId"].ToString(); string orgid = User.OrgId; List <RoleListInfo> rolelist = new List <RoleListInfo>(); using (EPortalEntities entity = new EPortalEntities()) { rolelist = (from r in entity.RoleMasters join Userro in entity.UserRoles on new { orgid = r.OrganizationID, Userid = selectedUser.Id, roleid = r.Id } equals new { orgid = Userro.OrganizationID, Userid = Userro.UserId, roleid = Userro.RoleId } into j1 from Userro in j1.DefaultIfEmpty() where r.OrganizationID == orgid select new RoleListInfo { Id = r.Id, Code = r.Code, Name = r.Name, Selected = (Userro == null ? false : true) }).ToList(); } return(Json(rolelist, JsonRequestBehavior.AllowGet)); }
public JsonResult GetTestList(UserTypeUserList user) { //string orgid = Session["OrgId"].ToString(); string orgid = User.OrgId; List <TestList> org = new List <TestList>(); using (EPortalEntities entity = new EPortalEntities()) { org = (from o in entity.Tests join at in entity.ApplicantTests on new { orgid = o.OrganizationID, testid = o.Id, Applicantid = user.Id, activetest = true, } equals new { orgid = at.OrganizationID, testid = at.TestId, Applicantid = at.ApplicantId, activetest = at.RowState } into j1 from at in j1.DefaultIfEmpty() where o.OrganizationID == orgid && o.IsPublish == true select new TestList { Id = o.Id, TestCode = o.TestCode, TestName = o.TestName, Selected = at == null ? false : true, AlreadyApplied = (from aa in entity.UserAnswers where aa.OrganizationID == orgid && aa.ApplicantId == user.Id && aa.TestId == o.Id select aa).FirstOrDefault() == null ? false : true }).ToList(); } return(Json(org, JsonRequestBehavior.AllowGet)); }
public JsonResult SendMailQA(UserTypeUserList selectedUser) { bool sendmail = false; //string orgid = Session["OrgId"].ToString(); string orgid = User.OrgId; //string userid = Session["UserId"].ToString(); string usermailid = string.Empty; List <TestApplyQuestionList> question = null; List <TotalQuestionList> totalnoofquestion = new List <TotalQuestionList>(); int result = 0; string errmsg = string.Empty; string testname = string.Empty; List <byte[]> pdfname = new List <byte[]>(); using (EPortalEntities entity = new EPortalEntities()) { var getusertest = (from ut in entity.ApplicantTests where ut.OrganizationID == orgid && ut.ApplicantId == selectedUser.Id select ut).ToList(); if (getusertest.Count() > 0) { foreach (var item in getusertest) { testname = (from t in entity.Tests where t.OrganizationID == orgid && t.Id == item.TestId select t.TestName).FirstOrDefault(); #region Get All question And Answer question = (from tq in entity.TestQuestions join q in entity.Questions on new { orgid = tq.OrganizationID, Questid = tq.QuestionId } equals new { orgid = q.OrganizationID, Questid = q.Id } join qs in entity.Questionsources on new { orgid = q.OrganizationID, questionsource = q.SourceId } equals new { orgid = qs.OrganizationID, questionsource = qs.Id } into j1 from qs in j1.DefaultIfEmpty() where tq.OrganizationID == orgid && tq.TestId == item.TestId select new TestApplyQuestionList { QuestionId = tq.QuestionId, QuestionText = q.Question1, SourceText = qs != null ? qs.ResourceText : "", QuestionNo = tq.SequenceNo, TestQuestionoptionList = (from qo in entity.QuestionOptions join an in entity.QuestionAnswars on new { orgid = qo.OrganizationID, questionid = tq.QuestionId, optionid = qo.Id } equals new { orgid = an.OrganizationID, questionid = an.QuestionId, optionid = an.QuestionAnswarId } into j2 from an in j2.DefaultIfEmpty() where qo.OrganizationID == orgid && qo.QuestionId == tq.QuestionId select new TestQuestionoptionList { OptionId = qo.Id, OptionText = qo.QuestionOption1, QuestionAns = an == null ? false : true, Selected = (from useran in entity.UserAnswers where useran.OrganizationID == orgid && useran.TestId == item.TestId && useran.QuestionId == tq.QuestionId && useran.optionId == qo.Id && useran.ApplicantId == selectedUser.Id select useran).FirstOrDefault() == null ? false : true }).ToList(), }).ToList(); #endregion StringBuilder markup = PreparedMarkupforPDF(question, testname); pdfname.Add(ConvertHtmlToPdf(markup, testname, selectedUser.Id)); } } else { errmsg = "User don't have any test."; } } if (errmsg == string.Empty) { string body = "Please find the attached file regarding user's Test Question and Answer."; string heading = "Test " + testname + " Question and Answer"; sendmail = homecontroller.SendMail(selectedUser.Email, heading, body, pdfname); } return(Json(new { sendmail = sendmail, errmsg = errmsg }, JsonRequestBehavior.AllowGet)); }