Пример #1
0
        /// <summary>
        /// Configures Fluent Web API to use a custom reply instead of its default behavior when responding to the <paramref name="route"/>.
        /// </summary>
        public static IPutRoute <T, TKey> ReplyWith <T, TKey>(this IPutRoute <T, TKey> route, Func <Responder, TKey, T, IHttpActionResult> func)
            where T : class, IApiModel <TKey>
        {
            if (route == null)
            {
                throw new ArgumentNullException("route");
            }

            if (func == null)
            {
                throw new ArgumentNullException("func");
            }

            ((Route <T, TKey>)route).ReplyOnPut = (r, o, m) => func(r, (TKey)o, m);
            return(route);
        }
Пример #2
0
        /// <summary>
        /// Configures the <paramref name="route"/> to use the given <paramref name="method"/> to update an instance of <typeparamref name="T"/>.
        /// </summary>
        /// <typeparam name="T">A model class that implements <see cref="IApiModel"/></typeparam>
        /// <typeparam name="TKey">The type of the key that identifies the model</typeparam>
        public static IPutRoute <T, TKey> UpdateUsing <T, TKey>(this IPutRoute <T, TKey> route, Action <TKey, T> method)
            where T : class, IApiModel <TKey>
        {
            if (route == null)
            {
                throw new ArgumentNullException("route");
            }

            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            ((Route <T, TKey>)route).Updater = (o, m) => method((TKey)o, m);
            return(route);
        }