HttpStatusCode CheckRole(HttpActionContext actionContext) { try { var address = actionContext.Request.RequestUri; string MethodName = actionContext.Request.Method.Method.ToLower(); string ControllerName = actionContext.ControllerContext.ControllerDescriptor.ControllerName.ToLower(); string ActionName = actionContext.ActionDescriptor.ActionName.ToLower(); aModel db = new aModel(); xTaiKhoan taiKhoan = db.xTaiKhoan.Find(Convert.ToInt32(actionContext.Request.Headers.GetValues("IDAccount").ToList()[0])); if (taiKhoan == null) { return(HttpStatusCode.NotFound); } xPhanQuyen phanQuyen = db.xPhanQuyen.FirstOrDefault(x => x.IDNhomQuyen == taiKhoan.IDNhomQuyen && ((x.MacDinh && x.Action.Equals(ActionName) && x.Method.Equals(MethodName)) || (!x.MacDinh && x.Controller.Equals(ControllerName) && x.Action.Equals(ActionName) && x.Method.Equals(MethodName)))); if (phanQuyen == null) { return(HttpStatusCode.NotFound); } //if (userFeature.TrangThai == 3) // return HttpStatusCode.BadRequest; return(HttpStatusCode.OK); } catch { return(HttpStatusCode.BadRequest); } }
public static void RegisterDatabase() { //aModel db = (aModel)ModuleHelper.HttpConfiguration.DependencyResolver.GetService(typeof(aModel)); aModel db = new aModel(); Database.SetInitializer(new MigrateDatabaseToLatestVersion <aModel, MyConfiguration>()); db.Database.Initialize(false); }
public RepositoryCollection(aModel db) { this.db = db; }
public Repository(aModel db) { Context = db; }