예제 #1
0
        public async Task <Recipe> Create(Recipe toCreate)
        {
            AssignIdentifier(toCreate);
            var dbModel = Map(toCreate);

            _dbContext.Recipes.Add(dbModel);
            await _dbContext.SaveChangesAsync();

            return(await Get(toCreate.Id));
        }
        private async Task MigrateDeletionFlag()
        {
            var recipes = _context.Recipes.ToList();

            recipes.ForEach(r => r.IsDeleted = false);
            await _context.SaveChangesAsync();
        }
예제 #3
0
        public async Task <bool> DeleteAll(List <TEntity> entities)
        {
            await using RecipeBookDbContext context = this._factory.CreateDbContext();
            context.Set <TEntity>().RemoveRange(entities);
            await context.SaveChangesAsync();

            return(true);
        }
예제 #4
0
        public async Task <TEntity> Update(TEntity entity)
        {
            await using RecipeBookDbContext context = this._factory.CreateDbContext();
            context.Set <TEntity>().Update(entity);
            await context.SaveChangesAsync();

            return(entity);
        }
예제 #5
0
        public async Task <TEntity> Create(TEntity entity)
        {
            await using RecipeBookDbContext context = this._factory.CreateDbContext();
            var newEntry = await context.Set <TEntity>().AddAsync(entity);

            await context.SaveChangesAsync();

            return(newEntry.Entity);
        }