示例#1
0
        public async Task <IActionResult> PutClient(int id, Client client)
        {
            if (id != client.Id)
            {
                return(BadRequest());
            }

            _context.Entry(client).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#2
0
        public async Task <T> AddAsync(T entity, CancellationToken cancellationToken = default)
        {
            await DbContext.Set <T>().AddAsync(entity, cancellationToken);

            await DbContext.SaveChangesAsync(cancellationToken);

            return(entity);
        }
示例#3
0
 public async Task SaveChangesAsync()
 {
     await _context.SaveChangesAsync();
 }