Esempio n. 1
0
 public async Task <Picture> GetPictureByKeyAsync(int pictureKey)
 {
     using (var context = new AOLContext())
     {
         var pictureRepo = context.EntityRepository <Picture>();
         return(await pictureRepo.Query().FirstOrDefaultAsync(p => p.PictureKey == pictureKey));
     }
 }
Esempio n. 2
0
        public async Task <Article> GetArticleByCodeAsync(string code)
        {
            using (var context = new AOLContext())
            {
                var articleRepo = context.EntityRepository <Article>();

                return(await articleRepo.Query().Where(a => a.Deleted == false && a.Code == code).FirstOrDefaultAsync());
            }
        }
Esempio n. 3
0
        public async Task <IEnumerable <Article> > GetArticlesAsync()
        {
            using (var context = new AOLContext())
            {
                var articleRepo = context.EntityRepository <Article>();

                return(await articleRepo.Query().Where(a => a.Deleted == false).Take(10).ToListAsync());
            }
        }
Esempio n. 4
0
        public async Task UpdatePictureAsync(Picture picture)
        {
            picture.State = EntityState.Modified;
            using (var context = new AOLContext())
            {
                var pictureRepo = context.EntityRepository <Picture>();
                pictureRepo.UpdateEntity(picture);

                await context.SaveChangesAsync();
            }
        }
Esempio n. 5
0
        public async Task <Picture> AddPictureAsync()
        {
            var picture = new Picture()
            {
                PictureTypeId = 2, State = Entity.EntityState.Added
            };

            using (var context = new AOLContext())
            {
                var pictureRepo = context.EntityRepository <Picture>();

                pictureRepo.AddEntity(picture);

                await context.SaveChangesAsync();

                return(picture);
            }
        }