Exemplo n.º 1
0
        public IActionResult GetJobsFromCRMGrouped([FromBody] GetJobsQueryStringModel queryString)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            var todaysDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 0, 0, 0);

            var queryStringModel = new GetJobsQueryStringModel()
            {
                ApiKey          = "0a947558-f14f-4823-b948-e52533c45684",
                CompletedBefore = new FilterCompletedBefore()
                {
                    FilterValue = todaysDate.AddDays(0)
                },
                CompletedAfter = new FilterCompletedAfter()
                {
                    FilterValue = todaysDate.AddDays(-5)
                }
            };

            var requestObject = new GetJobsFromServiceTitanQuery(queryStringModel);
            var result        = _mediator.Send(requestObject).Result;

            stopWatch.Stop();
            var groupedByCreator = result.ApiResults.GroupBy(j => j.CreatedBy.Name).OrderBy(c => c.Key).ToList();

            var groupedByHour = result.ApiResults.GroupBy(j => (DateTime.Parse(j.CreatedOn)).Hour).OrderBy(g => g.Key).ToList();

            return(Ok(result.ApiResults));
        }
Exemplo n.º 2
0
        public IActionResult GetJobsFromCRM([FromBody] GetJobsQueryStringModel queryString)
        {
            var requestObject = new GetJobsFromServiceTitanQuery(queryString);
            var result        = _mediator.Send(requestObject).Result;


            return(Ok(result.ApiResults));
        }