Exemple #1
0
        protected void Application_AuthenticateRequest(object sender, EventArgs args)
        {
            if (User == null || User.Identity.AuthenticationType != "Forms") return;

            using (var dbContext = new StudentRegistrationEntities())
            {

                var id = (FormsIdentity)User.Identity;
                var firstOrDefault = dbContext.Employees.FirstOrDefault(e => e.Email == id.Name);

                if (firstOrDefault == null) return;

                var employeeId = firstOrDefault.Id;

                var employee = (from em in dbContext.Employees
                    where em.Id == employeeId
                    select em).FirstOrDefault();

                if (employee == null) return;
                var roles = new string[employee.Roles.Count];

                var i = 0;

                foreach (var r in employee.Roles)
                {
                    roles[i++] = r.Role1;
                }

                HttpContext.Current.User = new GenericPrincipal(id, roles);
            }
        }
 public CourseOfferingRepository(StudentRegistrationEntities dbContext)
 {
     _dbContext = dbContext;
 }
Exemple #3
0
 public StudentRepository(StudentRegistrationEntities dbContext)
 {
     _dbContext = dbContext;
 }