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(); }
public ProvinceServices(SOITEntities db) { this.db = db; // db = new SOITEntities(); }
public UserProfileService(SOITEntities db) { this.db = db; }
public ReportsController() { dbContext = new SOITEntities(); }
public EmployeeController() { dbcontext = new SOITEntities(); }