コード例 #1
0
        public void InsertSmallFilesReturnsErrorIfNullSmallImageIds()
        {
            var request = new ProjectInsertSmallFilesRequest()
            {
                Id = ObjectId.GenerateNewId().ToString()
            };
            var response = new MongoProject().InsertSmallFiles(MockMongoDatabase.Object, request);

            Assert.IsFalse(String.IsNullOrEmpty(response.Error));
        }
コード例 #2
0
        public void InsertSmallFilesReturnsErrorIfIdEmpty()
        {
            var request = new ProjectInsertSmallFilesRequest()
            {
                Id = String.Empty
            };
            var response = new MongoProject().InsertSmallFiles(MockMongoDatabase.Object, request);

            Assert.IsFalse(String.IsNullOrEmpty(response.Error));
        }
コード例 #3
0
        public ProjectResponse InsertSmallFiles(string id, IList <string> fileIds)
        {
            var request = new ProjectInsertSmallFilesRequest()
            {
                Id = id
            };

            request.SmallFileIds.AddRange(fileIds);
            var response = new ProjectService.Project().InsertSmallFiles(request);

            return(response);
        }
コード例 #4
0
        private ProjectResponse InsertSmallFilesHelper(Project service, string id)
        {
            var fileIds = new List <string>()
            {
                ObjectId.GenerateNewId().ToString(), ObjectId.GenerateNewId().ToString()
            };
            var request = new ProjectInsertSmallFilesRequest()
            {
                Id = id
            };

            request.SmallFileIds.AddRange(fileIds);
            return(service.InsertSmallFiles(request));
        }
コード例 #5
0
        public ProjectResponse InsertSmallFiles(IMongoDatabase db, ProjectInsertSmallFilesRequest request)
        {
            if (request.SmallFileIds == null || request.SmallFileIds.Count == 0)
            {
                return(new ProjectResponse()
                {
                    Error = "File ids cannot be null or empty"
                });
            }

            // Reads the projects with specified id in the db
            var readRequest = new ProjectRequest()
            {
                Id = request.Id
            };
            var project = Read(db, readRequest).Project;

            var collection = db.GetCollection <ProjectStructure>("Project");

            project.SmallFileIds.AddRange(request.SmallFileIds.Where(x => !project.SmallFileIds.Contains(x)));
            UpdateDefinition <ProjectStructure> update;

            //Deals with going back in the workflow
            //Only update the state if not gone backwards in project workflow
            if (project.Progress == ProjectStructure.Types.State.Largeadded)
            {
                update = Builders <ProjectStructure> .Update.Set(x => x.SmallFileIds, project.SmallFileIds)
                         .Set(x => x.Progress, ProjectStructure.Types.State.Smalladded);
            }
            else
            {
                update = Builders <ProjectStructure> .Update.Set(x => x.SmallFileIds, project.SmallFileIds);
            }

            var updateResponse = collection.UpdateOne(x => x.Id.Equals(request.Id), update);
            var response       = new ProjectStructure()
            {
                Id = request.Id
            };

            response.SmallFileIds.AddRange(request.SmallFileIds);
            return(new ProjectResponse()
            {
                Project = response
            });
        }
コード例 #6
0
ファイル: Project.cs プロジェクト: TomMckiernan/MosaicProject
 public ProjectResponse InsertSmallFiles(ProjectInsertSmallFilesRequest request)
 {
     return(new MongoProject().InsertSmallFiles(database, request));
 }