Exemple #1
0
        /// <summary>
        /// Handles the "GetModel" request as an asynchronous operation.
        /// </summary>
        /// <param name="modelId">The model identifier.</param>
        /// <param name="ct">The cancellation token.</param>
        public virtual async Task HandleGetModelAsync(string modelId, CancellationToken ct = default)
        {
            try {
                var model = await Manager.GetModelAsync(modelId, ct);

                model.Id = "EasyData";
                await WriteOkJsonResponseAsync(HttpContext, async (jsonWriter, cancellationToken) => {
                    await WriteGetModelResponseAsync(jsonWriter, model, cancellationToken);
                }, ct);
            }
            catch (EasyDataManagerException ex) {
                HttpContext.Response.StatusCode = StatusCodes.Status404NotFound;
                await WriteErrorJsonResponseAsync(HttpContext, $"Model [{modelId}] not found. \r\nReason:" + ex.Message, ct);
            }
        }