示例#1
0
        public async Task DeleteFile(int fileId)
        {
            var user = await userAccess.GetUser();

            var file = await dbContext.Files
                       .Include(f => f.Comments)
                       .FirstAsync(f => f.Id == fileId);

            dbContext.Comments.RemoveRange(file.Comments);

            await dbContext.SaveChangesAsync();

            dbContext.Remove(file);

            await dbContext.SaveChangesAsync();

            logger.LogInformation(user.Id + ": deleted a file!(ID:" + fileId + ")");
        }
示例#2
0
 async Task ICustomerRepository <Customer> .Delete(Customer customer)
 {
     var ent = _context.Remove(customer).Entity;
     await _context.SaveChangesAsync();
 }