Ejemplo n.º 1
0
        private bool HasAccess(string id, out Template template)
        {
            template = null;
            string userId = User.Identity.GetUserId();
            var    user   = _userRepository.Find(userId);

            if (user == null)
            {
                return(false);
            }

            template = _templateRepository.Find(id);
            if (template == null)
            {
                return(true); // allow create
            }
            // user must be member
            return(template.OrganizationId == user.Id ||
                   user.Organizations.Contains(template.OrganizationId));
        }