コード例 #1
0
ファイル: DoctorController.cs プロジェクト: ingenthr/workshop
        public async Task <IActionResult> DoctorPatient([FromBody] PatientAssign assign)
        {
            IMutateInBuilder <dynamic> builder = _bucket.MutateIn <dynamic>(assign.Doctor);

            builder.ArrayAddUnique("patients", assign.Patient, true);
            var result = await builder.ExecuteAsync();

            if (result.Success)
            {
                return(Ok(assign));
            }
            return(CouchbaseError(result));
        }
コード例 #2
0
        /// <summary>
        /// Insert a fragment of type <typeparamref name="TContent"/> into a document of type <typeparamref name="TDocument"/>,
        /// using a given lambda expression path.
        /// </summary>
        /// <typeparam name="TDocument">Type of the parent document.</typeparam>
        /// <typeparam name="TContent">Type of the subdocument.</typeparam>
        /// <param name="builder"><see cref="ILookupInBuilder{TDocument}"/> where the the subdocument lookup is being built.</param>
        /// <param name="path">Lambda expression path that navigates to the subdocument from the parent document.</param>
        /// <param name="value">Value to insert at <paramref cref="path"/>.</param>
        /// <param name="createParents">If true, create parents along the path if they don't exist.</param>
        /// <returns>The <paramref name="builder"/> for expression chaining.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="builder"/> or <paramref name="path"/> is null.</exception>
        public static IMutateInBuilder <TDocument> Insert <TDocument, TContent>(this IMutateInBuilder <TDocument> builder,
                                                                                Expression <Func <TDocument, TContent> > path, TContent value, bool createParents)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            return(builder.Insert(ParsePath(builder as ITypeSerializerProvider, path), value, createParents));
        }
コード例 #3
0
        /// <summary>
        /// Remove a fragment of type <typeparamref name="TContent"/> from a document of type <typeparamref name="TDocument"/>,
        /// using a given lambda expression path.
        /// </summary>
        /// <typeparam name="TDocument">Type of the parent document.</typeparam>
        /// <typeparam name="TContent">Type of the subdocument.</typeparam>
        /// <param name="builder"><see cref="ILookupInBuilder{TDocument}"/> where the the subdocument lookup is being built.</param>
        /// <param name="path">Lambda expression path that navigates to the subdocument from the parent document.</param>
        /// <returns>The <paramref name="builder"/> for expression chaining.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="builder"/> or <paramref name="path"/> is null.</exception>
        public static IMutateInBuilder <TDocument> Remove <TDocument, TContent>(this IMutateInBuilder <TDocument> builder,
                                                                                Expression <Func <TDocument, TContent> > path)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            return(builder.Remove(ParsePath(builder as ITypeSerializerProvider, path)));
        }
コード例 #4
0
        public async Task <IActionResult> Notes(string patientid, [FromBody] PatientNote notes)
        {
            // timestamp must be now, ignore/override any values posted in
            notes.Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds();

            IMutateInBuilder <dynamic> builder = _bucket.MutateIn <dynamic>(patientid)
                                                 .ArrayAppend("notes", notes, false);
            var result = await builder.ExecuteAsync();

            if (result.Success)
            {
                return(Ok(notes));
            }
            return(CouchbaseError(result));
        }
コード例 #5
0
        /// <summary>
        /// Add a unique fragment of type <typeparamref name="TContent"/> into an array in a document of type <typeparamref name="TDocument"/>,
        /// using a given lambda expression path.
        /// </summary>
        /// <typeparam name="TDocument">Type of the parent document.</typeparam>
        /// <typeparam name="TContent">Type of the array within the parent document.</typeparam>
        /// <typeparam name="TElement">Type of the array element being added.</typeparam>
        /// <param name="builder"><see cref="ILookupInBuilder{TDocument}"/> where the the subdocument lookup is being built.</param>
        /// <param name="path">Lambda expression path that navigates to the array from the parent document.</param>
        /// <param name="value">Value to insert into the array.</param>
        /// <param name="createParents">If true, create parents along the path if they don't exist.</param>
        /// <returns>The <paramref name="builder"/> for expression chaining.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="builder"/> or <paramref name="path"/> is null.</exception>
        public static IMutateInBuilder <TDocument> ArrayAddUnique <TDocument, TContent, TElement>(this IMutateInBuilder <TDocument> builder,
                                                                                                  Expression <Func <TDocument, TContent> > path, TElement value, bool createParents)
            where TContent : ICollection <TElement>
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            return(builder.ArrayAddUnique(ParsePath(builder as ITypeSerializerProvider, path), value, createParents));
        }