/// <summary> /// Returns a new export function id for an object /// </summary> /// <param name="search">Search</param> /// <param name="projectId">Project Id</param> /// <param name="objectId">Object Id</param> /// <param name="subCategory">Sub Category</param> /// <returns>New export function id</returns> private async Task <int> GetNewExportFuntionIdForObjectInternal(IFindFluent <ExportFunctionIdCounter, ExportFunctionIdCounter> search, string projectId, string objectId, string subCategory) { ExportFunctionIdCounter exportFunctionIdCounter = await search.FirstOrDefaultAsync(); if (exportFunctionIdCounter == null) { exportFunctionIdCounter = new ExportFunctionIdCounter(); exportFunctionIdCounter.ProjectId = projectId; exportFunctionIdCounter.ObjectId = objectId; exportFunctionIdCounter.SubCategory = subCategory; exportFunctionIdCounter.CurExportFunctionId = 0; } ++exportFunctionIdCounter.CurExportFunctionId; if (!string.IsNullOrEmpty(exportFunctionIdCounter.Id)) { await _IdCounterCollection.ReplaceOneAsync(t => t.Id == exportFunctionIdCounter.Id, exportFunctionIdCounter); } else { exportFunctionIdCounter.Id = Guid.NewGuid().ToString(); await _IdCounterCollection.InsertOneAsync(exportFunctionIdCounter); } return(exportFunctionIdCounter.CurExportFunctionId); }
/// <summary> /// Returns a new export function id for an object /// </summary> /// <param name="projectId">Project Id</param> /// <param name="objectId">Object Id</param> /// <returns>New export function id</returns> public async Task <int> GetNewExportFuntionIdForObject(string projectId, string objectId) { ExportFunctionIdCounter exportFunctionIdCounter = await _IdCounterCollection.Find(t => t.ProjectId == projectId && t.ObjectId == objectId).FirstOrDefaultAsync(); if (exportFunctionIdCounter == null) { exportFunctionIdCounter = new ExportFunctionIdCounter(); exportFunctionIdCounter.ProjectId = projectId; exportFunctionIdCounter.ObjectId = objectId; exportFunctionIdCounter.CurExportFunctionId = 0; } ++exportFunctionIdCounter.CurExportFunctionId; if (!string.IsNullOrEmpty(exportFunctionIdCounter.Id)) { await _IdCounterCollection.ReplaceOneAsync(t => t.Id == exportFunctionIdCounter.Id, exportFunctionIdCounter); } else { exportFunctionIdCounter.Id = Guid.NewGuid().ToString(); await _IdCounterCollection.InsertOneAsync(exportFunctionIdCounter); } return(exportFunctionIdCounter.CurExportFunctionId); }