public async Task <ActionResult <UserGetDto> > DeleteUser(int id) { await using var transaction = await _context.Database.BeginTransactionAsync(IsolationLevel.Serializable); try { var user = await _context.GetActiveUsers() .FirstOrDefaultAsync(u => u.Id == id); if (user == null) { return(NotFound()); } var blockedState = await _context.GetBlockedStateAsync(); user.StateId = blockedState.Id; _context.Entry(user).State = EntityState.Modified; await _context.SaveChangesAsync(); await transaction.CommitAsync(); return(_mapper.Map <UserGetDto>(user)); } catch (DBConcurrencyException e) { Console.WriteLine(e); return(Conflict()); } }