protected override bool IsAuthorized(HttpActionContext actionContext) { var userName = Thread.CurrentPrincipal.Identity.Name; Method methodObj = new Method(); var action = actionContext.Request.Method.Method.ToLower(); var method = actionContext.ActionDescriptor.ActionName; var nParams = actionContext.Request.GetRouteData().Values.Count; using (var repo = FluentNHibernateHelper.GetRepository()) { methodObj = repo.Where <Method>(m => m.Params == nParams && m.Name == method && m.Action == action).FirstOrDefault(); if (methodObj != null) { UserMethodSub ums = new UserMethodSub(userName, methodObj.Id); if (UserRoles.user_method_dict.ContainsKey(ums)) { return(true); } } } return(false); }
public static User GetUserDetail(string username, string password) { using (IRepository repository = FluentNHibernateHelper.GetRepository()) { return(repository.Where <User>(user => user.UserName == username && user.PassWord == password).FirstOrDefault()); } }
public IHttpActionResult GetById(long id) { using (var repository = FluentNHibernateHelper.GetRepository()) { Blog blog = repository.Get <Blog>(id); return(Ok(blog)); } }
public IHttpActionResult GetAll() { using (var repository = FluentNHibernateHelper.GetRepository()) { var blogs = repository.GetAll <Blog>(); return(Ok(blogs)); } }
public static bool Login(string username, string password) { using (var repository = FluentNHibernateHelper.GetRepository()) { var user = repository.Where <User>(u => u.UserName == username && u.PassWord == password); return(user.Count != 0); } }
private void LoadUserMethod() { UserRoles.user_method_dict = new Dictionary <UserMethodSub, bool>(new UserMethodEqualityComparer()); IList <UserMethod> userMethodList = new List <UserMethod>(); using (var repo = FluentNHibernateHelper.GetRepository()) { userMethodList = repo.GetAll <UserMethod>(); } foreach (var userMethod in userMethodList) { UserRoles.user_method_dict.Add(new UserMethodSub(userMethod), true); } }
/// <summary> /// Constructor /// </summary> public AuthRepository() { repo = FluentNHibernateHelper.GetRepository(); }