public override async Task Update(Group group)
        {
            group.Track(false, GetActor());
            var activeGroup = await Get(group.Id).ConfigureAwait(false);

            await ExponentialBackoff(DocumentDbService.UpdateDocument(FormatId(activeGroup.Id.ToString()), group));
        }
        protected override async Task Update(string id, Group group)
        {
            group.Track(false, GetActor());
            var activeGroup = await Get(id).ConfigureAwait(false);

            await ExponentialBackoff(DocumentDbService.UpdateDocument(FormatId(activeGroup.Id), group));
        }
Exemple #3
0
        public NewClubViewModel()
        {
            NewClub            = new Clubs();
            _documentDbService = new DocumentDbService("Clubs");

            SaveCmd = new Command(async() => await InsertItemAsync(NewClub));
        }
Exemple #4
0
        public async Task <IEnumerable <Role> > GetRoles(string grain, string securableItem = null, string roleName = null)
        {
            var customParams = grain + securableItem + roleName;

            return(roleName != null ?
                   await DocumentDbService.GetDocuments <Role>("roles", "byname", customParams) :
                   await DocumentDbService.GetDocuments <Role>("roles", "bysecitem", customParams));
        }
Exemple #5
0
        public async Task <IEnumerable <Permission> > GetPermissions(string grain, string securableItem = null, string permissionName = null)
        {
            var customParams = grain + securableItem + permissionName;

            return(permissionName != null ?
                   await DocumentDbService.GetDocuments <Permission>("permissions", "byname", customParams) :
                   await DocumentDbService.GetDocuments <Permission>("permissions", "bysecitem", customParams));
        }
Exemple #6
0
        public EditClubViewModel(Clubs club)
        {
            Club = club;

            _documentDbService = new DocumentDbService("Clubs");
            _messageService    = new MessageService();

            DeleteCmd = new Command(Delete);
            UpdateCmd = new Command(Update);
        }
Exemple #7
0
        public async Task <GranularPermission> GetGranularPermission(string userId)
        {
            var perm = await DocumentDbService.GetDocument <GranularPermission>(FormatId(userId));

            if (perm == null)
            {
                throw new NotFoundException <GranularPermission>(userId);
            }

            return(perm);
        }
Exemple #8
0
        private static void InitializeServices()
        {
            IAppConfiguration config = new AppConfiguration();

            ddbService = new DocumentDbService(config);

            faceApiService = new FaceApiService(ConfigurationManager.AppSettings["FaceApiSubscriptionKey"]);

            storageService =
                new StorageService(ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ConnectionString,
                                   "faces");
        }
Exemple #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            DocumentDbService documentDbService = new DocumentDbService(Configuration.GetSection("CosmosDb"));
            // Store a test document for read load testing
            var     testDocumentService = new TestDocumentService();
            JObject toRead = (JObject)testDocumentService.GetDocument().DeepClone();

            toRead.Add("id", Constants.IdForReadTesting);
            documentDbService.UpsertItemAsync(toRead).Wait();
            services.AddSingleton <IDocumentDbService>(documentDbService);
            services.AddSingleton <ITestDocumentService>(testDocumentService);
            services.AddMvc();
        }
Exemple #10
0
        public IQueryable <DocumentDto> GetTenLatestUpdates()
        {
            try
            {
                var documents = new DocumentDbService().GetLatestDocuments();

                return(documents);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
        public async Task <ActionResult> Comment(string content, Guid documentId)
        {
            var comment = new Comment
            {
                Content    = content,
                Author     = DashDocsClaims.DisplayName,
                CustomerId = DashDocsClaims.CustomerId,
                DocuemtnId = documentId,
                Id         = Guid.NewGuid().ToString()
            };
            var docucmentDbContext = new DocumentDbService();
            await docucmentDbContext.CreateCommentAsync(comment);

            return(RedirectToAction("Index", new { documentId = documentId }));
        }
Exemple #12
0
        public async Task AddOrUpdateGranularPermission(GranularPermission granularPermission)
        {
            var userId = FormatId(granularPermission.Id);
            var perm   = await DocumentDbService.GetDocument <GranularPermission>(userId);

            var currentUser = GetActor();

            if (perm == null)
            {
                granularPermission.Track(true, currentUser);
                await DocumentDbService.AddDocument(userId, granularPermission);
            }
            else
            {
                granularPermission.Track(false, currentUser);
                await DocumentDbService.UpdateDocument(userId, granularPermission);
            }
        }
Exemple #13
0
        /// <summary>
        /// Initialises a new instance of the <see cref="DocumentDbAccess"/> class.
        /// </summary>
        /// <param name="dbConfig">The database config.</param>
        /// <param name="configManager">The document config manager.</param>
        public DocumentDbAccess(DocumentDbConfig dbConfig, ServiceDbConfigManager configManager)
        {
            if (dbConfig == null)
            {
                throw new ArgumentNullException(nameof(dbConfig));
            }
            if (configManager == null)
            {
                throw new ArgumentNullException(nameof(configManager));
            }

            _dbConfig      = dbConfig;
            _configManager = configManager;
            _queryPolicy   = new DocumentQueryPolicy();

            var dbService = new DocumentDbService(configManager, dbConfig);

            _dbService = dbService;
            _client    = dbService.Client;
        }
        public async Task <ActionResult> Index()
        {
            Guid documentId = Guid.Empty;

            if (Request.QueryString["documentId"] != null && Guid.TryParse(Request.QueryString["documentId"], out documentId))
            {
                var dbContext = new DashDocsContext();
                var document  = dbContext.Documents.Single(d => d.Id == documentId);

                var docucmentDbContext = new DocumentDbService();
                var comments           = await docucmentDbContext.GetCommentsAsync(documentId, DashDocsClaims.CustomerId);

                var result = new KeyValuePair <Document, List <Comment> >(document, comments);
                return(View(result));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public override async Task <Group> Get(string id)
        {
            try
            {
                return(await base.Get(FormatId(id)).ConfigureAwait(false));
            }
            catch (NotFoundException <Group> )
            {
                Logger.Debug($"Exact match for Group {id} not found.");

                // now attempt to find a group that starts with the supplied ID
                var groups = await DocumentDbService.GetDocuments <Group>(GetGroupIdPrefix(id));

                var activeGroup = groups.FirstOrDefault(g => !g.IsDeleted);
                if (activeGroup == null)
                {
                    throw new NotFoundException <Group>($"Could not find {typeof(Group).Name} entity with ID {id}");
                }

                return(activeGroup);
            }
        }
Exemple #16
0
 public void DeleteResource(string id)
 {
     DocumentDbService.DeleteDocument <IdentityResource>(id);
 }
Exemple #17
0
 public void UpdateResource(string id, IdentityResource apiResource)
 {
     DocumentDbService.UpdateDocument(id, apiResource);
 }
Exemple #18
0
 public void AddResource(IdentityResource apiResource)
 {
     DocumentDbService.AddDocument(apiResource.Name, apiResource);
 }
Exemple #19
0
 public IdentityResource GetResource(string id)
 {
     return(DocumentDbService.GetDocument <IdentityResource>(id).Result);
 }
        public ClubListViewModel()
        {
            _documentDbService = new DocumentDbService("Clubs");

            AddClubCmd = new Command(() => App.Current.MainPage.Navigation.PushAsync(new Views.NewClub()));
        }
 protected override async Task Update(string id, User model)
 {
     model.Track(false, GetActor());
     await ExponentialBackoff(DocumentDbService.UpdateDocument(FormatId(model.Identifier), model)).ConfigureAwait(false);
 }
 public override async Task <IEnumerable <Group> > GetAll()
 {
     return(await DocumentDbService.GetDocuments <Group>("group"));
 }
Exemple #23
0
 public ApiResource GetResource(string id)
 {
     return(DocumentDbService.GetDocument <ApiResource>(id).Result);
 }