public void Can_Get_For_Date_Range(int count, int daysAgo, int expected)
        {
            IEnumerable <WorkflowInstancePoco> instances = Scaffold.Instances(count);

            List <WorkflowInstanceViewModel> results = _service.GetAllInstancesForDateRange(DateTime.Now.AddDays(daysAgo));

            // all instances are incomplete, so return regardless of daysAgo value
            Assert.Equal(expected, results.Count);

            foreach (WorkflowInstancePoco instance in instances)
            {
                instance.CompletedDate = DateTime.Now.AddDays(daysAgo - 10);
                _service.UpdateInstance(instance);
            }

            results = _service.GetAllInstancesForDateRange(DateTime.Now.AddDays(daysAgo));

            // all instances are now completed prior to the oldest date so should return an empty set
            Assert.Empty(results);
        }
示例#2
0
        public IHttpActionResult GetAllInstancesForRange(int days)
        {
            try
            {
                List <WorkflowInstance> instances = _instancesService.GetAllInstancesForDateRange(DateTime.Now.AddDays(days * -1));

                return(Json(new
                {
                    items = instances,
                    total = instances.Count
                }, ViewHelpers.CamelCase));
            }
            catch (Exception e)
            {
                const string error = "Error getting instances for date range";
                Log.Error(error, e);
                return(Content(HttpStatusCode.InternalServerError, ViewHelpers.ApiException(e, error)));
            }
        }