Exemplo n.º 1
0
        private ProjectResponse InsertLargeFileHelper(Project service, string id)
        {
            var insertRequest = new ProjectInsertLargeFileRequest()
            {
                Id = id, LargeFileId = ObjectId.GenerateNewId().ToString(), Location = "//MasterLocation//test.jpg"
            };

            return(service.InsertLargeFile(insertRequest));
        }
Exemplo n.º 2
0
        public ProjectResponse InsertLargeFile(string id, string fileId, string masterLocation)
        {
            var request = new ProjectInsertLargeFileRequest()
            {
                Id = id, LargeFileId = fileId, Location = masterLocation
            };
            var response = new ProjectService.Project().InsertLargeFile(request);

            return(response);
        }
        public void InsertLargeFileReturnsErrorIfNullMasterLocation()
        {
            var request = new ProjectInsertLargeFileRequest()
            {
                Id = ObjectId.GenerateNewId().ToString(), LargeFileId = ObjectId.GenerateNewId().ToString()
            };
            var response = new MongoProject().InsertLargeFile(MockMongoDatabase.Object, request);

            Assert.IsFalse(String.IsNullOrEmpty(response.Error));
        }
        public void InsertLargeFileReturnsErrorIfIdEmpty()
        {
            var request = new ProjectInsertLargeFileRequest()
            {
                Id = String.Empty
            };
            var response = new MongoProject().InsertLargeFile(MockMongoDatabase.Object, request);

            Assert.IsFalse(String.IsNullOrEmpty(response.Error));
        }
Exemplo n.º 5
0
        public ProjectResponse InsertLargeFile(IMongoDatabase db, ProjectInsertLargeFileRequest request)
        {
            var collection = db.GetCollection <ProjectStructure>("Project");

            if (String.IsNullOrEmpty(request.Id) || String.IsNullOrEmpty(request.LargeFileId) || String.IsNullOrEmpty(request.Location))
            {
                return(new ProjectResponse()
                {
                    Error = "Id or location 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;
            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.Created)
            {
                update = Builders <ProjectStructure> .Update.Set(x => x.LargeFileId, request.LargeFileId)
                         .Set(x => x.Progress, ProjectStructure.Types.State.Largeadded)
                         .Set(x => x.MasterLocation, request.Location);
            }
            else
            {
                update = Builders <ProjectStructure> .Update.Set(x => x.LargeFileId, request.LargeFileId)
                         .Set(x => x.MasterLocation, request.Location);
            }

            collection.UpdateOne(x => x.Id.Equals(request.Id), update);
            return(new ProjectResponse()
            {
                Project = new ProjectStructure()
                {
                    Id = request.Id, LargeFileId = request.LargeFileId, MasterLocation = request.Location
                }
            });
        }
Exemplo n.º 6
0
 public ProjectResponse InsertLargeFile(ProjectInsertLargeFileRequest request)
 {
     return(new MongoProject().InsertLargeFile(database, request));
 }