Getting all group members from Box

I wrote below code to get all Groups and its members list from Box API

 

private static async Task getEnterpriseGroups()

    {

      BoxCollection<BoxGroup> groups = await boxclient.GroupsManager.GetAllGroupsAsync();       

      foreach (BoxGroup group in groups.Entries)

      {

        BoxCollection<BoxGroupMembership> memberships = await boxclient.GroupsManager

  .GetAllGroupMembershipsForGroupAsync(group.Id);

        foreach (BoxGroupMembership member in memberships.Entries)

        {

          using (var db = new MigraionContext())

          {

            var grp = new BoxGroups

            {

              Date = DateTime.Now,

               groupId = group.Id,

               groupName = group.Name,

                userName = member.User.Name,

                userId = member.User.Id,

                 userLogin = member.User.Login 

            };

            Console.WriteLine(grp.groupName + " Member Name : " + grp.userName);

            db.Groups.Add(grp);

            db.SaveChanges();

          }

        }

      }

    }

To view or add a comment, sign in

More articles by Akhilesh Gandhi

  • Better version of Automated digital marketing

    Our AI team has made tremendous improvements from V1 to V2. The new post does not look like a Robotic post, as it did…

    2 Comments
  • Issues with the first cut of automated AI-generated marketing via Quikit

    We are building automated digital marketing which auto-generated posts for all Social Media platforms and did first POC…

    3 Comments
  • Difficult Journey of Tech Founder Building Product

    As a Tech Founder, my passion has always been building products. But has that alone made me successful? Not quite.

    5 Comments
  • Enhancing Workplace Efficiency with Multilingual HRMS

    Bringing in a first-of-its-kind HRMS that is multilingual and bringing an Intranet first approach In today's globalized…

    2 Comments
  • Why should RawData be called Lead in CRM?

    Most Conventional CRM calls any form of data as Lead and we at Emossy believe it is an issue, We think only potential…

    1 Comment
  • Key elements of Successful Business

    The four key elements of any successful business have to be People, strategy, Execution, and Cash This can be achieved…

    1 Comment
  • Scaling Up with Emossy

    I had the opportunity to attend a session with Verne Harnish who is CEO of the Scaling up Program. The session stuck me…

    1 Comment
  • SAAS Critical Numbers to Track

    Below are list of a few Critical numbers you need to track while building a SAAS Company.

  • SOC2 Compliance

    SOC2 defines criteria on how you will manage your customer's data based on trust, security, integrity, availability…

  • How B2B Supply Chain Can Be Improved?

    One major challenge faced by any e-commerce business is managing the supply chain and deliver the order in optimum time…

    1 Comment

Insights from the community

Others also viewed

Explore topics