Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
 public RepositoryCollection(aModel db)
 {
     this.db = db;
 }
Пример #4
0
 public Repository(aModel db)
 {
     Context = db;
 }