public static string CurrentUser_UserType(this HtmlHelper HtmlHelper) { SFSAcademyEntities db = new SFSAcademyEntities(); HttpContext context = HttpContext.Current; int UserId = Convert.ToInt32(context.Session["UserId"]); var V = db.USERS.Select(s => new { s.ID, s.ADMIN_IND, s.EMP_IND, s.STDNT_IND, s.PARNT_IND }).Distinct().Where(a => a.ID.Equals(UserId)).FirstOrDefault(); if (V.ADMIN_IND.ToString().Equals("Y")) { return("Admin"); } else if (V.EMP_IND.ToString().Equals("Y")) { return("Empoyee"); } else if (V.STDNT_IND.ToString().Equals("Y")) { return("Student"); } else if (V.PARNT_IND.ToString().Equals("Y")) { return("Parent"); } else { return("Visitor"); } }
public static bool Permitted_To(this HtmlHelper HtmlHelper, string _Action, string _Controller) { if (_Controller == null) { return(false); } else if (_Action == null) { return(false); } bool result = false; HttpContext context = HttpContext.Current; int UserId = Convert.ToInt32(context.Session["UserId"]); SFSAcademyEntities db = new SFSAcademyEntities(); foreach (var entity in db.USERS_ACCESS.Select(s => new { s.USRS_ID, s.CTL, s.ACTN, s.IS_ACCBLE }).Distinct().Where(a => a.USRS_ID.Equals(UserId)).ToList()) { if (entity.ACTN.ToString().Equals(_Action) && entity.CTL.ToString().Equals(_Controller) && entity.IS_ACCBLE.ToString().Equals("Y")) { result = true; break; } } return(result); }
public static DataTable CurrentUser_SubjectBatch(this HtmlHelper HtmlHelper) { SFSAcademyEntities db = new SFSAcademyEntities(); HttpContext context = HttpContext.Current; int UserId = Convert.ToInt32(context.Session["UserId"]); var SubjectBatchTable = new DataTable(); SubjectBatchTable.Columns.Add("SubjectId", typeof(int)); SubjectBatchTable.Columns.Add("BatchId", typeof(string)); var SubjectBatch = (from USR in db.USERS join EMP in db.EMPLOYEEs on USR.ID equals EMP.USRID join ESUB in db.EMPLOYEES_SUBJECT on EMP.ID equals ESUB.EMP_ID join SUB in db.SUBJECTs on ESUB.SUBJ_ID equals SUB.ID join BA in db.BATCHes on SUB.BTCH_ID equals BA.ID where USR.ID == UserId select new { SUBJECT_ID = SUB.ID, BATCH_ID = BA.ID }).ToList(); foreach (var entity in SubjectBatch.ToList()) { var row = SubjectBatchTable.NewRow(); row["SubjectId"] = entity.SUBJECT_ID; row["BatchId"] = entity.BATCH_ID; SubjectBatchTable.Rows.Add(row); } return(SubjectBatchTable); }
public static string Configuration_Value(this HtmlHelper HtmlHelper, string Config_Key) { SFSAcademyEntities db = new SFSAcademyEntities(); var SubjectBatch = (from C in db.CONFIGURATIONs where C.CONFIG_KEY == Config_Key select new { CONFIG_VALUE = C.CONFIG_VAL }).FirstOrDefault(); return(SubjectBatch.CONFIG_VALUE.ToString()); }
public static int Check_Reminders(this HtmlHelper HtmlHelper) { SFSAcademyEntities db = new SFSAcademyEntities(); HttpContext context = HttpContext.Current; int UserId = Convert.ToInt32(context.Session["UserId"]); int Count = 0; var SubjectBatch = (from EV in db.EVENTs join EDE in db.EMPLOYEE_DEPARTMENT_EVENT on EV.ID equals EDE.EV_ID join ED in db.EMPLOYEE_DEPARTMENT on EDE.EMP_DEPT_ID equals ED.ID join EP in db.EMPLOYEEs on ED.ID equals EP.EMP_DEPT_ID where EP.USRID == UserId select new { EVENT_ID = EV.ID }).ToList(); foreach (var entity in SubjectBatch.ToList()) { Count = Count + 1; } return(Count); }