コード例 #1
0
        public async Task <StoreViynl> Create(StoreViynl entity)
        {
            if (entity == null)
            {
                throw new Exception("Entity cannot be null");
            }
            var result = await _dbContext
                         .StoreTracks.AddAsync(entity);

            await _dbContext.SaveChangesAsync();

            return(result.Entity);
        }
コード例 #2
0
        public async Task <StoreViynl> Update(StoreViynl entity)
        {
            if (entity == null)
            {
                throw new Exception("Entity cannot be null");
            }

            _dbContext.StoreTracks.Attach(entity);
            var entry = _dbContext.Entry(entity);

            entry.State = EntityState.Modified;

            await _dbContext.SaveChangesAsync();

            return(entry.Entity);
        }