Exemple #1
0
        private void IsUserAuthorized(AuthorizationContext filterContext)
        {
            //if (filterContext.Result == null)
            //    return;

            //if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
            //{
            //    var vr = new ViewResult();
            //    vr.ViewName = View;
            //    ViewDataDictionary dict = new ViewDataDictionary();
            //    dict.Add("Message", "Sorry you are not Authorized to Perform this Action");
            //    vr.ViewData = dict;
            //    var result = vr;
            //    filterContext.Result = result;
            //}
            //string username = filterContext.HttpContext.User.Identity.Name;
            //// get rolename
            //string actionname = filterContext.ActionDescriptor.ActionName;

            if (filterContext.Result == null)
            {
                string username = filterContext.HttpContext.User.Identity.Name;
                string query    = $@"INSERT INTO [UserAccessLog]([UserName],[AccessTime])VALUES('{username}','{DateTime.Now}')";

                using (SOITEntities context = new SOITEntities())
                {
                    context.Database.ExecuteSqlCommand(query);
                }
            }
            //           if (CanSystemAccess != "true")
            //           {
            //               var vr = new ViewResult();
            //               vr.ViewName = "UnAuthorizeAccess";
            //               ViewDataDictionary dict = new ViewDataDictionary();
            //               dict.Add("Message", "System is not accessing yet. wait for some time");
            //               vr.ViewData = dict;
            //               var result = vr;
            //               filterContext.Result = result;
            //           }
            //           return;
            //       }

            //if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
            //{
            //    var vr = new ViewResult();
            //    vr.ViewName = View;
            //    ViewDataDictionary dict = new ViewDataDictionary();
            //    dict.Add("Message", "Sorry you are not Authorized to Perform this Action");
            //    vr.ViewData = dict;
            //    var result = vr;
            //    filterContext.Result = result;
            //}
        }
 public SOITEntities Init()
 {
     return(dbContext ?? (dbContext = new SOITEntities()));
 }
 public DashboardController()
 {
     dbContext = new SOITEntities();
 }
Exemple #4
0
 public ProvinceServices(SOITEntities db)
 {
     this.db = db;
     //  db = new SOITEntities();
 }
Exemple #5
0
 public UserProfileService(SOITEntities db)
 {
     this.db = db;
 }
 public ReportsController()
 {
     dbContext = new SOITEntities();
 }
Exemple #7
0
 public EmployeeController()
 {
     dbcontext = new SOITEntities();
 }