Пример #1
0
        public override void CreateRole(string roleName)
        {
            MongoRole r = new MongoRole
            {
                Id       = Guid.NewGuid(),
                RoleName = roleName
            };

            Task task = _roleCollection.InsertOneAsync(r);

            task.Wait();
        }
Пример #2
0
        public override void CreateRole(string roleName)
        {
            Task <MongoRole> role = _roleCollection.Find(r => r.RoleName == roleName).SingleOrDefaultAsync();

            role.Wait();
            if (role.Result != null)
            {
                return;
            }

            MongoRole mr = new MongoRole
            {
                Id       = Guid.NewGuid(),
                RoleName = roleName
            };

            Task task = _roleCollection.InsertOneAsync(mr);

            task.Wait();
        }