Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1.         public override void OnActionExecuting(ActionExecutingContext filterContext)
  2.         {
  3.             RouteValueDictionary path;
  4.             object objId;
  5.             if (filterContext.ActionParameters.TryGetValue("id", out objId))
  6.             {
  7.                 var id = new Guid(objId.ToString());
  8.                 var user = filterContext.HttpContext.User as SMPrincipal;
  9.  
  10.                 if (user != null && user.AccountID != id)
  11.                 {
  12.                     var userRoleType = user.getRoleType();
  13.                     if (userRoleType == RoleEnum.Patient)
  14.                     {
  15.                         var followerRepo = new FollowerRepository(new SMContext());
  16.                         if (!followerRepo.IsAccountIdFollowingViewId(user.AccountID, id))
  17.                         {
  18.                             path = MVC.User.Access.Denied().GetRouteValueDictionary();
  19.                             filterContext.Result = new RedirectToRouteResult(path);
  20.                         }
  21.  
  22.                     }
  23.  
  24.                 }
  25.             }
  26.             base.OnActionExecuting(filterContext);
  27.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement