private static Category<ObjectId> CreateCategory(string name , IdentityUserRole editRole, IdentityUserRole? viewRole , ObjectId? id = null, ObjectId? parentID = null) { var category = new Category<ObjectId>() { Name = name, Permissions = new List<KeyValuePair<int, string>>() { new KeyValuePair<int, string>((int)CategoryPermission.Insert, editRole.ToString()), new KeyValuePair<int, string>((int)CategoryPermission.Edit, editRole.ToString()), new KeyValuePair<int, string>((int)CategoryPermission.Delete, editRole.ToString()), } }; if (viewRole != null) { category.Permissions.Add( new KeyValuePair<int, string>((int)CategoryPermission.View, viewRole.Value.ToString())); } category.CategoryID = id ?? ObjectId.GenerateNewId(); category.ParentCategoryID = parentID; return category; }