コード例 #1
0
 /// <summary>
 /// Gets a single piece of pixel art from the database.
 /// </summary>
 public static async Task <PixelArt> GetSinglePixelAsync(int id, PixelDBContext _context)
 {
     //get pixel art with corrosponding id
     return(await(from pixel in _context.PixelArts
                  where pixel.PixelArtID == id
                  select pixel).SingleAsync()); //gets a single item from the database
 }
コード例 #2
0
        /// <summary>
        /// Gets a page of pixel arts from the database.
        /// </summary>
        public async static Task <List <PixelArt> > GetPageOfPixelsAsync(PixelDBContext _context, int PageSize, int pageNum)
        {
            List <PixelArt> pixelArts = await(_context.PixelArts.OrderBy(p => p.DateCreated)).Skip(PageSize * (pageNum - 1))  // Skip() must be before Take()
                                        .Take(PageSize)
                                        .ToListAsync();

            return(pixelArts);
        }
コード例 #3
0
 public GalleryController(PixelDBContext context, IConfiguration config, BlobStorageHelper blobHelper)
 {
     _context    = context;
     _BlobHelper = blobHelper;
 }
コード例 #4
0
 //Gets all commissions from the database.
 public async static Task <int> GetTotalCommissionsAsync(PixelDBContext _context)
 {
     return(await(from c in _context.Commissions
                  select c).CountAsync());
 }
コード例 #5
0
 public async static Task <CommissionsLog> GetSingleCommissionAsync(int id, PixelDBContext _context)
 {
     return(await(from commission in _context.Commissions
                  where commission.ComissionID == id
                  select commission).SingleAsync());
 }
コード例 #6
0
        public async static Task <List <CommissionsLog> > GetPageOfCommissionsAsync(PixelDBContext _context, int pageSize, int pageNum)
        {
            List <CommissionsLog> commissionsLogs = await(_context.Commissions.OrderBy(c => c.DateCompleted)).Skip(pageSize * (pageNum - 1)).Take(pageSize).ToListAsync();

            return(commissionsLogs);
        }
コード例 #7
0
 /// <summary>
 /// Gets all pixels from the database.
 /// </summary>
 public async static Task <int> GetTotalPixelsAsync(PixelDBContext _context)
 {
     return(await(from p in _context.PixelArts
                  select p).CountAsync());
 }
コード例 #8
0
 public CommissionsController(PixelDBContext context, IConfiguration config)
 {
     _context = context;
 }