示例#1
0
        public async Task <IActionResult> ShareDocumentWithGroups(string[] groups, IEnumerable <string> documentsToShareWithGroups)
        {
            //Note
            //
            //pattern for id will be
            //   [Type]_[Id]
            // where Type is FileDocument or Folder
            //   and the Id is the Id of the content to share

            foreach (var item in documentsToShareWithGroups)
            {
                var details   = item.Split('_');
                var type      = details[0];
                var contentId = details[1];

                //TODO split Group logic to carry provider type with groups (eg  "[connectionGroup]_[CG1]")
                //TODO refactor claimtype to be dynamic and selectable, not hardcoded
                foreach (var group in groups)
                {
                    //note: Groups will be in the following pattern
                    //       {grouptype}_{groupId}
                    // grouptype is the security implementation group such as Connection Group
                    // and groupid is just the id
                    var groupDetail = group.Split('_');
                    var groupType   = groupDetail[0];
                    var groupId     = groupDetail[1];
                    await _resourceManager.AddGroupResourceClaimAsync(contentId, type, groupId, groupType, "View");
                }
            }
            return(new JsonResult(groups));

            //var document = await GetDocument(id);

            //foreach (var user in addedResources)
            //{
            //    await _log.LogEventShareAsync(document, GetCurrentUserId(), user.UserId);
            //}
        }