예제 #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());
 }
 public CommissionsController(PixelDBContext context, IConfiguration config)
 {
     _context = context;
 }