Example #1
0
        public async Task <LeftCollection> List(LeftQuery query)
        {
            var dbQuery = await query.Create(this.Entities);

            var total = await dbQuery.CountAsync();

            dbQuery = dbQuery.Skip(query.SkipTo(total)).Take(query.Limit);
            var results = await mapper.ProjectLeft(dbQuery).ToListAsync();

            return(new LeftCollection(query, total, results));
        }
Example #2
0
        /// <summary>
        /// Gets the left query.
        /// </summary>
        /// <returns>System.String.</returns>
        public string GetLeftQuery()
        {
            if (File.Exists(LeftQuery))
            {
                return(File.ReadAllText(LeftQuery));
            }

            if (LeftQuery.EndsWith(".sql"))
            {
                return(File.ReadAllText(LeftQuery));
            }

            return(LeftQuery);
        }
            async Task List()
            {
                //This could be more complete
                var repo = mockup.Get <ILeftRepository>();
                await repo.AddRange(new LeftInput[] { LeftTests.CreateInput(), LeftTests.CreateInput(), LeftTests.CreateInput() });

                var query  = new LeftQuery();
                var result = await repo.List(query);

                Assert.Equal(query.Limit, result.Limit);
                Assert.Equal(query.Offset, result.Offset);
                Assert.Equal(3, result.Total);
                Assert.NotEmpty(result.Items);
            }
            async Task List()
            {
                var totalItems = 3;

                var controller = mockup.Get <LeftsController>();

                for (var i = 0; i < totalItems; ++i)
                {
                    Assert.NotNull(await controller.Add(LeftTests.CreateInput()));
                }

                var query  = new LeftQuery();
                var result = await controller.List(query);

                Assert.Equal(query.Limit, result.Limit);
                Assert.Equal(query.Offset, result.Offset);
                Assert.Equal(3, result.Total);
                Assert.NotEmpty(result.Items);
            }
 public async Task <LeftCollection> List([FromQuery] LeftQuery query)
 {
     return(await repo.List(query));
 }
Example #6
0
 public LeftCollection(LeftQuery query, int total, IEnumerable <Left> items) : base(query, total, items)
 {
 }