Пример #1
0
 /// <summary>
 /// Updates an application with a new originator.
 /// </summary>
 /// <param name="applicationId">The application identifier.</param>
 /// <param name="originator">The originator.</param>
 /// <returns>
 /// The updated application.
 /// </returns>
 public Application UpdateOriginator(string applicationId, AuthenticatedApplicationUser originator)
 {
     return this.DoUpdateOriginator(applicationId, originator);
 }
Пример #2
0
        /// <summary>
        /// Updates an application with a new originator.
        /// </summary>
        /// <param name="applicationId">The application identifier.</param>
        /// <param name="originator">The originator.</param>
        /// <returns>
        /// The updated application.
        /// </returns>
        protected override iApply.DataContract.Application DoUpdateOriginator(string applicationId, AuthenticatedApplicationUser originator)
        {
            MongoQueryBuilder queryBuilder = new MongoQueryBuilder();
            queryBuilder.AddIfNotNull(iApplyDb.Application._ID, applicationId, a => new BsonObjectId(new ObjectId(a)));

            MongoCollection<BsonDocument> applicationCollection = this.database.GetCollection(iApplyDb.Application._COLLECTION_NAME);
            BsonDocument document = applicationCollection.FindOne(queryBuilder.ToAndEqQuery());

            if (document == null)
            {
                return null;
            }

            var application = BsonConverter.ConvertToObjectViaJson<iApply.DataContract.Application>(document);
            application.CreatedBy = originator;
            application.AssignedTo = originator.Id;
            application.AssignedToDisplayName = originator.DisplayName;
            application.ModifiedBy = originator.Id;

            BsonDocument applicationDocument = BsonConverter.ConvertToBsonViaJson(application);
            applicationCollection.Save(applicationDocument);

            return application;
        }
Пример #3
0
 /// <summary>
 /// Updates an application with a new originator.
 /// </summary>
 /// <param name="applicationId">The application identifier.</param>
 /// <param name="originator">The originator.</param>
 /// <returns>
 /// The updated application.
 /// </returns>
 protected abstract Application DoUpdateOriginator(string applicationId, AuthenticatedApplicationUser originator);
        public void UpdateOriginator()
        {
            if (!this.connected)
            {
                Assert.Inconclusive("Could not connect to database instance '{0}'", this.client.GetServer().Instance.Address);
            }

            AuthenticatedApplicationUser newOriginator = new AuthenticatedApplicationUser
                                                         {
                                                             Id = new ObjectId().ToString()
                                                         };

            iApply.DataContract.Application application = this.dataAccess.UpdateOriginator(MockTestData.Applications[0][2], newOriginator);
            Assert.AreEqual(application.CreatedBy.Id, newOriginator.Id);
        }