示例#1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "pages/webhook")] HttpRequest?request)
        {
            try
            {
                logger.LogInformation("Received webhook request");

                if (request == null)
                {
                    logger.LogError($"{nameof(request)} is null");
                    return(new StatusCodeResult((int)HttpStatusCode.BadRequest));
                }

                using var streamReader = new StreamReader(request.Body);
                var requestBody = await streamReader.ReadToEndAsync().ConfigureAwait(false);

                if (string.IsNullOrEmpty(requestBody))
                {
                    logger.LogError($"{nameof(request)} body is null");
                    return(new StatusCodeResult((int)HttpStatusCode.BadRequest));
                }

                var result = await webhookReceiver.ReceiveEvents(requestBody).ConfigureAwait(false);

                logger.LogInformation("Webhook request completed");

                return(result);
            }
            catch (Exception ex)
            {
                logger.LogError(ex.ToString());
                return(new StatusCodeResult((int)HttpStatusCode.InternalServerError));
            }
        }
示例#2
0
        /// <summary>
        /// The intro text
        /// </summary>
        public static string Intro(HttpRequest?request, bool light = false)
        {
            return($@"
<div style=""float:left; padding:0px 10px 10px 0px;""><img src=""/favicon?light={light}"" style=""width:100px;""/></div>
This API allows calculating hashes for publicly available content... SHA1mone!
<br/>
This allows you to show a badge with checksum for online content.
<div style=""clear:both""/>
<h5>Example</h5>
When calculating the hash for the Google favicon (<img src=""https://www.google.com/favicon.ico"" style=""vertical-align: middle;""/>), which is linked at: https://www.google.com/favicon.ico
<p>
<code title=""this example has been made simple, be sure to URL-encode the `url` argument"">{WebUtility.HtmlEncode($@"<img src=""{(string.IsNullOrWhiteSpace(request?.Host.Host)?"":"http://")}{request?.Host.Host}/SHA1mone/?url=https://www.google.com/favicon.ico""/>")}</code>
</p>
Unless Google changes the favicon, the expected response is:<br/>
<code style=""margin-left:20px; font-family:Consolas;font-size:15px;"">49263695F6B0CDD72F45CF1B775E660FDC36C606</code>
<p>Badge calculated by the API:</p>
<a href=""/SHA1mone/?url=https%3A%2F%2Fwww.google.com%2Ffavicon.ico"">
<img src=""/SHA1mone/?url=https%3A%2F%2Fwww.google.com%2Ffavicon.ico&light={light}""/>
</a>
<p>
The API will be size-restricted, for an unlimited-cross-platform experience install the command-line tool:
</p>
<h5>Alternative: commandline</h5>
Install Michael checksum on your machine:
<pre><code>dotnet tool install -g michaelchecksum.console</code></pre>
To calculate a checkum of a local file:
<pre><code>michaelchecksum mydownloadedfile.zip</code></pre>
To calculate a checkum of a remote:
<pre><code>michaelchecksum http://download.com/mydownloadedfile.zip</code></pre>
");
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "graph/purge/{soc}/{socId}")] HttpRequest?request,
            int soc,
            Guid socId,
            [DurableClient] IDurableOrchestrationClient starter)
        {
            try
            {
                var socRequest = new SocRequestModel
                {
                    Soc   = soc,
                    SocId = socId,
                    IsDraftEnvironment = environmentValues.IsDraftEnvironment,
                };

                if (!socRequest.IsDraftEnvironment)
                {
                    return(new BadRequestResult());
                }

                logger.LogInformation($"Received graph purge for SOC {soc} request");

                string instanceId = await starter.StartNewAsync(nameof(LmiImportOrchestrationTrigger.GraphPurgeSocOrchestrator), socRequest).ConfigureAwait(false);

                logger.LogInformation($"Started orchestration with ID = '{instanceId}' for SOC {soc}.");

                return(starter.CreateCheckStatusResponse(request, instanceId));
            }
            catch (Exception ex)
            {
                logger.LogError(ex.ToString());
                return(new StatusCodeResult((int)HttpStatusCode.InternalServerError));
            }
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "subscription/")] HttpRequest?request)
        {
            logger.LogInformation("Request received for SubscriptionRegistration");
            try
            {
                var apiSuffix = environmentValues.EnvironmentNameApiSuffix;
                if (!string.IsNullOrWhiteSpace(apiSuffix))
                {
                    apiSuffix = "-" + apiSuffix
                                .Replace("(", string.Empty, StringComparison.Ordinal)
                                .Replace(")", string.Empty, StringComparison.Ordinal)
                                .Replace(" ", "-", StringComparison.Ordinal).ToLowerInvariant();
                }

                await subscriptionRegistrationService.RegisterSubscription("DFC-Api-LMI-Delta-Reports" + apiSuffix).ConfigureAwait(false);

                return(new OkResult());
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Error creating SubscriptionRegistration");
                return(new InternalServerErrorResult());
            }
        }
        public async override Task OnInitializedAsync()
        {
            await base.OnInitializedAsync().ConfigureAwait(false);

            if (string.IsNullOrWhiteSpace(PersonGroupId))
            {
                Error = "Person group ID not set!";

                // Generate generic requests for demo purposes.
                _getPeopleRequest           = PersonGroupPersonRequestGenerator.List("group-id");
                _createPersonRequest        = PersonGroupPersonRequestGenerator.Create("group-id", "Person's name", "{\"custom\":\"data\"}");
                _updatePersonRequest        = PersonGroupPersonRequestGenerator.Update("group-id", Guid.Empty.ToString(), "Person's name", "{\"custom\":\"data\"}");
                _deletePersonRequest        = PersonGroupPersonRequestGenerator.Delete("group-id", Guid.Empty.ToString());
                _getGroupTrainStatusRequest = PersonGroupRequestGenerator.CheckTraining("group-id");
                _trainRequest = PersonGroupRequestGenerator.Train("group-id");

                RefreshRequests();
                return;
            }

            string groupId = PersonGroupId !;

            _getPeopleRequest           = PersonGroupPersonRequestGenerator.List(groupId);
            _createPersonRequest        = PersonGroupPersonRequestGenerator.Create(groupId, "Person's name", "{\"custom\":\"data\"}");
            _updatePersonRequest        = PersonGroupPersonRequestGenerator.Update(groupId, Guid.Empty.ToString(), "Person's name", "{\"custom\":\"data\"}");
            _deletePersonRequest        = PersonGroupPersonRequestGenerator.Delete(groupId, Guid.Empty.ToString());
            _getGroupTrainStatusRequest = PersonGroupRequestGenerator.CheckTraining(groupId);
            _trainRequest = PersonGroupRequestGenerator.Train(groupId);

            RefreshRequests();
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "graph/refresh")] HttpRequest?request,
            [DurableClient] IDurableOrchestrationClient starter)
        {
            try
            {
                var orchestratorRequestModel = new OrchestratorRequestModel
                {
                    IsDraftEnvironment  = environmentValues.IsDraftEnvironment,
                    SuccessRelayPercent = environmentValues.SuccessRelayPercent,
                };

                if (!orchestratorRequestModel.IsDraftEnvironment)
                {
                    return(new BadRequestResult());
                }

                logger.LogInformation("Received graph refresh request");

                string instanceId = await starter.StartNewAsync(nameof(LmiImportOrchestrationTrigger.GraphRefreshOrchestrator), orchestratorRequestModel).ConfigureAwait(false);

                logger.LogInformation($"Started orchestration with ID = '{instanceId}'.");

                return(starter.CreateCheckStatusResponse(request, instanceId));
            }
            catch (Exception ex)
            {
                logger.LogError(ex.ToString());
                return(new StatusCodeResult((int)HttpStatusCode.InternalServerError));
            }
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "lmi/webhook")] HttpRequest?request,
            [DurableClient] IDurableOrchestrationClient starter)
        {
            try
            {
                logger.LogInformation("Received webhook request");

                bool isDraftEnvironment = environmentValues.IsDraftEnvironment;
                using var streamReader = new StreamReader(request?.Body !);
                var requestBody = await streamReader.ReadToEndAsync().ConfigureAwait(false);

                if (string.IsNullOrEmpty(requestBody))
                {
                    logger.LogError($"{nameof(request)} body is null");
                    return(new BadRequestResult());
                }

                string?instanceId          = null;
                var    webhookRequestModel = lmiWebhookReceiverService.ExtractEvent(requestBody);
                switch (webhookRequestModel.WebhookCommand)
                {
                case WebhookCommand.SubscriptionValidation:
                    return(new OkObjectResult(webhookRequestModel.SubscriptionValidationResponse));

                case WebhookCommand.PublishFromDraft:
                    if (!isDraftEnvironment)
                    {
                        return(new BadRequestResult());
                    }

                    instanceId = await starter.StartNewAsync(nameof(LmiImportOrchestrationTrigger.RefreshPublishedOrchestrator)).ConfigureAwait(false);

                    break;

                case WebhookCommand.PurgeFromPublished:
                    if (!isDraftEnvironment)
                    {
                        return(new BadRequestResult());
                    }

                    instanceId = await starter.StartNewAsync(nameof(LmiImportOrchestrationTrigger.PurgePublishedOrchestrator)).ConfigureAwait(false);

                    break;

                default:
                    return(new BadRequestResult());
                }

                logger.LogInformation($"Started orchestration with ID = '{instanceId}' for {webhookRequestModel.WebhookCommand}");

                return(starter.CreateCheckStatusResponse(request, instanceId));
            }
            catch (Exception ex)
            {
                logger.LogError(ex.ToString());
                return(new StatusCodeResult((int)HttpStatusCode.InternalServerError));
            }
        }
 private string GetSourcePathBase(HttpRequest?request)
 {
     if (sourcePathBaseSelector != null)
     {
         return(sourcePathBaseSelector(request));
     }
     return(sourcePathBase);
 }
 protected async Task <T?> MakeRequest <T>(HttpRequest?request)
     where T : class
 {
     Error = string.Empty;
     if (request == null)
     {
         Error = "Request is not set!";
         return(default !);
        public async Task UpdatePerson(PersonDto person)
        {
            _updatePersonRequest = PersonGroupPersonRequestGenerator.Update(PersonGroupId !, person.PersonId, person.Name, person.UserData);
            RefreshRequests();

            _ = await MakeRequest <string>(_updatePersonRequest).ConfigureAwait(false);

            await GetPeople();
        }
        public async Task DeletePerson(string personId)
        {
            _deletePersonRequest = PersonGroupPersonRequestGenerator.Delete(PersonGroupId !, personId);
            RefreshRequests();

            _ = await MakeRequest <string>(_deletePersonRequest).ConfigureAwait(false);

            await GetPeople();
        }
        public async Task CreatePerson(PersonDto person)
        {
            _createPersonRequest = PersonGroupPersonRequestGenerator.Create(PersonGroupId !, person.Name, person.UserData);
            RefreshRequests();

            // TODO: Parse PersonId
            _ = await MakeRequest <string>(_createPersonRequest).ConfigureAwait(false);

            await GetPeople();
        }
        public override async Task <InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context)
        {
            HttpRequest?request = context.HttpContext.Request;

            using (var reader = new StreamReader(request.Body))
            {
                string?content = await reader.ReadToEndAsync();

                return(await InputFormatterResult.SuccessAsync(content));
            }
        }
        public async Task DeleteFace(string faceId)
        {
            _getFaceRequest    = PersonGroupPersonFaceRequestGenerator.Get(PersonGroupId !, PersonId !, faceId);
            _updateFaceRequest = PersonGroupPersonFaceRequestGenerator.Update(PersonGroupId !, PersonId !, faceId, @"{""user"":""data""}");
            _deleteFaceRequest = PersonGroupPersonFaceRequestGenerator.Delete(PersonGroupId !, PersonId !, faceId);
            UpdateRequestList();

            _ = await MakeRequest <string>(_deleteFaceRequest).ConfigureAwait(false);

            // Refresh list.
            await GetPerson();
        }
        public async Task UpdateFace(FaceDto face)
        {
            _getFaceRequest    = PersonGroupPersonFaceRequestGenerator.Get(PersonGroupId !, PersonId !, face.PersistedFaceId);
            _updateFaceRequest = PersonGroupPersonFaceRequestGenerator.Update(PersonGroupId !, PersonId !, face.PersistedFaceId, face.UserData);
            _deleteFaceRequest = PersonGroupPersonFaceRequestGenerator.Delete(PersonGroupId !, PersonId !, face.PersistedFaceId);
            UpdateRequestList();

            _ = await MakeRequest <string>(_updateFaceRequest).ConfigureAwait(false);

            // Refresh list.
            await GetPerson();
        }
        private string GetTargetPathBase(HttpRequest?request)
        {
            if (targetPathBaseSelector != null)
            {
                return(targetPathBaseSelector(request));
            }

            string pathBaseString;

            pathBaseString = request?.PathBase.Value ?? string.Empty;
            pathBaseString = AddLeadingSlashIfNecessary(pathBaseString);
            pathBaseString = AddTrailingSlashIfNecessary(pathBaseString);
            return(pathBaseString);
        }
        public string GetValidatedLanguage(AuthenticatedUserExpanded?user, HttpRequest?request = null)
        {
            StringValues val = default;
            var          fromHeadersOrDefault = ValidatedOrDefault(
                (request?.Headers?.TryGetValue("Accept-Language", out val) ?? false) ? val.ToString() : Constants.DEFAULT_LANGUAGE,
                Constants.DEFAULT_LANGUAGE
                );

            if (user?.IsAnonymous ?? true)
            {
                return(fromHeadersOrDefault);
            }

            return(ValidatedOrDefault(user.Language, fromHeadersOrDefault));
        }
示例#18
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "lmi/webhook")] HttpRequest?request)
        {
            try
            {
                logger.LogInformation("Received webhook request");

                using var streamReader = new StreamReader(request?.Body !);
                var requestBody = await streamReader.ReadToEndAsync().ConfigureAwait(false);

                if (string.IsNullOrEmpty(requestBody))
                {
                    logger.LogError($"{nameof(request)} body is null");
                    return(new BadRequestResult());
                }

                var webhookRequestModel = lmiWebhookReceiverService.ExtractEvent(requestBody);
                switch (webhookRequestModel.WebhookCommand)
                {
                case WebhookCommand.SubscriptionValidation:
                    return(new OkObjectResult(webhookRequestModel.SubscriptionValidationResponse));

                case WebhookCommand.ReportDeltaForAll:
                    if (!environmentValues.IsDraftEnvironment)
                    {
                        return(new BadRequestResult());
                    }

                    return(new StatusCodeResult((int)await lmiWebhookReceiverService.ReportAll().ConfigureAwait(false)));

                case WebhookCommand.ReportDeltaForSoc:
                    if (!environmentValues.IsDraftEnvironment)
                    {
                        return(new BadRequestResult());
                    }

                    return(new StatusCodeResult((int)await lmiWebhookReceiverService.ReportSoc(webhookRequestModel.ContentId).ConfigureAwait(false)));

                default:
                    return(new BadRequestResult());
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex.ToString());
                return(new StatusCodeResult((int)HttpStatusCode.InternalServerError));
            }
        }
示例#19
0
        /// <summary>
        /// Captures the request body.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.String.</returns>
        public static string?CaptureRequestBody(HttpRequest?request)
        {
            if (request == null ||
                request.ContentLength == null ||
                !(request.ContentLength > 0) ||
                !request.Body.CanSeek
                )
            {
                return(null);
            }

            string?bodyContent =
                StreamUtility.CaptureAsStringAsync(request.BodyReader.AsStream(true)).Result;

            return(bodyContent);
        }
示例#20
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "subscription/")] HttpRequest?request)
        {
            logger.LogInformation("Request received for SubscriptionRegistration");
            try
            {
                await subscriptionRegistrationService.RegisterSubscription("DFC-Api-LMI-Delta-Reports").ConfigureAwait(false);

                return(new OkResult());
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Error creating SubscriptionRegistration");
                return(new InternalServerErrorResult());
            }
        }
        public async Task AddFace(FaceDto face, string imageUrl, string detectionModel)
        {
            _addFaceRequest = PersonGroupPersonFaceRequestGenerator.Add(
                PersonGroupId !,
                PersonId !,
                imageUrl,
                detectionModel,
                face.UserData);

            UpdateRequestList();

            _ = await MakeRequest <string>(_addFaceRequest).ConfigureAwait(false);

            // Refresh list.
            await GetPerson();
        }
示例#22
0
        public async Task PostNullRequestReturnsBadRequest()
        {
            // Arrange
            HttpRequest?request        = null;
            var         expectedResult = new StatusCodeResult((int)HttpStatusCode.BadRequest);
            var         function       = new PagesWebhookHttpTrigger(fakeLogger, fakewebhookReceiver);

            A.CallTo(() => fakewebhookReceiver.ReceiveEvents(A <string> .Ignored)).Returns(new StatusCodeResult(200));

            // Act
            var result = await function.Run(request).ConfigureAwait(false);

            // Assert
            var statusResult = Assert.IsType <StatusCodeResult>(result);

            Assert.Equal(expectedResult.StatusCode, statusResult.StatusCode);
        }
示例#23
0
        public async Task PatchReturnsBadRequestWhenNullRequest()
        {
            // Arrange
            const HttpStatusCode expectedResult = HttpStatusCode.BadRequest;
            HttpRequest?         request        = null;
            var function = new PatchAjaxRequestHttpTrigger(fakeLogger, fakeDocumentService);

            // Act
            var result = await function.Run(request, PathName, ValidNameValue).ConfigureAwait(false);

            // Assert
            A.CallTo(() => fakeDocumentService.GetAsync(A <Expression <Func <AppRegistrationModel, bool> > > .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeDocumentService.UpsertAsync(A <AppRegistrationModel> .Ignored)).MustNotHaveHappened();

            var statusResult = Assert.IsType <BadRequestResult>(result);

            Assert.Equal((int)expectedResult, statusResult.StatusCode);
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "job-groups/{socId}")] HttpRequest?request, Guid socId)
        {
            logger.LogInformation($"Getting job-group for {socId}");

            var jobGroupModel = await documentService.GetByIdAsync(socId).ConfigureAwait(false);

            if (jobGroupModel != null)
            {
                logger.LogInformation($"Returning {jobGroupModel.Soc} job-group detail");

                return(new OkObjectResult(jobGroupModel));
            }

            logger.LogWarning($"Failed to get job-group for {socId}");

            return(new NoContentResult());
        }
        private RequestDetails(HttpRequest?request)
        {
            if (request is null)
            {
                return;
            }

            Protocol    = request.Protocol;
            Method      = request.Method;
            Scheme      = request.Scheme;
            Host        = request.Host.Value;
            Path        = FluentUrl.Combine(request.PathBase, request.Path);
            QueryString = request.QueryString.Value;
            Url         = request.GetDisplayUrl();
            Headers     = request.Headers;
            Content     = request.Body;
            ContentType = request.ContentType;
        }
示例#26
0
    /// <summary>
    /// This examines the request to see if it matches a configured directory, and if there are any files with the
    /// configured default names in that directory.  If so this will append the corresponding file name to the request
    /// path for a later middleware to handle.
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public Task Invoke(HttpContext context)
    {
        if (context.Request.IsGetOrHeadMethod() &&
            context.Request.AcceptHeaderContainsHtml() &&
            context.Request.TryMatchPath(_matchUrl, true, out PathString subPath) &&
            (context.GetGraphQLToolOptions()?.Enable ?? true))
        {
            IDirectoryContents?dirContents = _fileProvider.GetDirectoryContents(subPath.Value);

            if (dirContents.Exists)
            {
                // Check if any of our default files exist.
                IFileInfo?file = _fileProvider.GetFileInfo(subPath.Value + _defaultFile);

                // TryMatchPath will make sure subpath always ends with a "/"
                // by adding it if needed.
                if (file.Exists)
                {
                    // If the path matches a directory but does not end in a slash,
                    // redirect to add the slash.
                    // This prevents relative links from breaking.
                    if (!context.Request.PathEndsInSlash())
                    {
                        context.Response.StatusCode = StatusCodes.Status301MovedPermanently;

                        HttpRequest?request  = context.Request;
                        var         redirect = UriHelper.BuildAbsolute(request.Scheme, request.Host,
                                                                       request.PathBase, request.Path + "/", request.QueryString);

                        context.Response.Headers[HeaderNames.Location] = redirect;

                        return(Task.CompletedTask);
                    }

                    // Match found, re-write the url.
                    // A later middleware will actually serve the file.
                    context.Request.Path =
                        new PathString(context.Request.Path.Value + _defaultFile);
                }
            }
        }

        return(_next(context));
    }
示例#27
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "appregistry/{path}")] HttpRequest?request, string path)
        {
            logger.LogInformation("Validating Delete AppRegistration for");

            if (string.IsNullOrWhiteSpace(path))
            {
                logger.LogWarning($"Missing value in request for '{nameof(path)}'");
                return(new BadRequestResult());
            }

            logger.LogInformation($"Attempting to get app registration for: {path}");
            var appRegistrationModels = await documentService.GetAsync(p => p.Path == path).ConfigureAwait(false);

            if (appRegistrationModels == null)
            {
                logger.LogWarning($"No app registration exists for path: {path}");
                return(new NoContentResult());
            }

            var appRegistrationModel = appRegistrationModels.FirstOrDefault();

            try
            {
                logger.LogInformation($"Attempting to delete app registration for: {appRegistrationModel.Path}");

                var result = await documentService.DeleteAsync(appRegistrationModel.Id).ConfigureAwait(false);

                if (result)
                {
                    logger.LogInformation($"Deleted app registration for: {appRegistrationModel.Path}");
                    return(new OkResult());
                }

                logger.LogError($"Error deleting app registration for: {appRegistrationModel.Path}");
                return(new UnprocessableEntityResult());
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Error deleting app registration with Delete for: {appRegistrationModel.Path}");
                return(new UnprocessableEntityResult());
            }
        }
        public override async Task OnInitializedAsync()
        {
            Error = string.Empty;

            await base.OnInitializedAsync().ConfigureAwait(false);

            if (string.IsNullOrWhiteSpace(PersonGroupId))
            {
                Error = "Person group ID not set!";
            }

            if (string.IsNullOrWhiteSpace(PersonId))
            {
                Error = "Person ID not set!";
            }

            if (!string.IsNullOrWhiteSpace(Error))
            {
                _personRequest  = PersonGroupPersonRequestGenerator.Get("group-id", Guid.Empty.ToString());
                _addFaceRequest = PersonGroupPersonFaceRequestGenerator.Add("group-id", Guid.Empty.ToString(), "http://image.url");
                _addFaceRequest = PersonGroupPersonFaceRequestGenerator.Add("group-id", Guid.Empty.ToString(), new byte[0]);
                _addFaceRequest = PersonGroupPersonFaceRequestGenerator.Get("group-id", Guid.Empty.ToString(), Guid.Empty.ToString());
                _addFaceRequest = PersonGroupPersonFaceRequestGenerator.Update("group-id", Guid.Empty.ToString(), Guid.Empty.ToString(), @"{""user"":""data""}");
                _addFaceRequest = PersonGroupPersonFaceRequestGenerator.Delete("group-id", Guid.Empty.ToString(), Guid.Empty.ToString());
                UpdateRequestList();

                return;
            }

            string groupId  = PersonGroupId !;
            string personId = PersonId !;

            _personRequest        = PersonGroupPersonRequestGenerator.Get(groupId, personId);
            _addFaceRequest       = PersonGroupPersonFaceRequestGenerator.Add(groupId, personId, "http://image.url");
            _addBinaryFaceRequest = PersonGroupPersonFaceRequestGenerator.Add(groupId, personId, new byte[0]);
            _getFaceRequest       = PersonGroupPersonFaceRequestGenerator.Get(groupId, personId, Guid.Empty.ToString());
            _updateFaceRequest    = PersonGroupPersonFaceRequestGenerator.Update(groupId, personId, Guid.Empty.ToString(), @"{""user"":""data""}");
            _deleteFaceRequest    = PersonGroupPersonFaceRequestGenerator.Delete(groupId, personId, Guid.Empty.ToString());
            UpdateRequestList();

            await GetPerson().ConfigureAwait(false);
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "job-groups")] HttpRequest?request)
        {
            logger.LogInformation("Getting all job-groups");

            var jobGroupModels = await documentService.GetAllAsync().ConfigureAwait(false);

            if (jobGroupModels != null && jobGroupModels.Any())
            {
                logger.LogInformation($"Returning {jobGroupModels.Count()} job-group summary items");

                var summaryModels = mapper.Map <IList <JobGroupSummaryItemModel> >(jobGroupModels);

                return(new OkObjectResult(summaryModels.OrderBy(o => o.Soc)));
            }

            logger.LogWarning("Failed to get any job-groups");

            return(new NoContentResult());
        }
示例#30
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "delta-reports")] HttpRequest?request)
        {
            logger.LogInformation("Getting all delta reports");

            var deltaReportModels = await deltaReportDocumentService.GetAllAsync().ConfigureAwait(false);

            if (deltaReportModels != null && deltaReportModels.Any())
            {
                logger.LogInformation($"Returning {deltaReportModels.Count()} delta reports");

                var results = mapper.Map <IList <DeltaReportSummaryApiModel> >(deltaReportModels);

                return(new OkObjectResult(results.OrderByDescending(o => o.CreatedDate)));
            }

            logger.LogWarning("Failed to get any delta reports");

            return(new NoContentResult());
        }